Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Best HTTP Released

Discussion in 'Assets and Asset Store' started by BestHTTP, Sep 11, 2013.

  1. alexanderFabula

    alexanderFabula

    Joined:
    Sep 1, 2019
    Posts:
    3
    Hej

    I'm using the plugin to collect som images from a database, but when building to a google app bundle (probably 64-bit version in-app bundle) I get the following error. The error does not occur when building an .apk.


    ERROR:
    2020-01-10 14:11:36.389 8369-8652/dk.portaplay.musvestar E/Unity: [637142622963882800] Ex [HTTPConnection]: Connector.Connect - Message: 1: mono-io-layer-error (111) at System.Net.Sockets.SocketAsyncResult.CheckIfThrowDelayedException () [0x00000] in <00000000000000000000000000000000>:0
    at BestHTTP.PlatformSupport.TcpClient.General.TcpClient.Connect (System.Net.IPEndPoint remoteEP) [0x00000] in <00000000000000000000000000000000>:0
    at BestHTTP.PlatformSupport.TcpClient.General.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, System.Int32 port) [0x00000] in <00000000000000000000000000000000>:0
    at BestHTTP.Connections.TCPConnector.Connect (BestHTTP.HTTPRequest request) [0x00000] in <00000000000000000000000000000000>:0
    at BestHTTP.Connections.HTTPConnection.ThreadFunc () [0x00000] in <00000000000000000000000000000000>:0
    at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
    at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.T
     
  2. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
  3. Afroman

    Afroman

    Joined:
    Aug 17, 2013
    Posts:
    43
    Hello @BestHTTP

    I have a feature request. I’m in the process of implementing SignalR Core with the plugin, currently working on error handling.

    I’ve deliberately let the SignalR Core access token expire to test an Unauthorized response from the negotiate endpoint. When it fails, In the HubConnection.OnError callback I receive an error string:
    The raw response (obtained by Charles) is:
    I’m very interested in accessing the HttpResponse from /negotiate, so I can inspect the response headers, but unfortunately the plugin doesn’t pass that information and there doesn’t seem to be a way to access it.

    I can see that OnNegotiationRequestFinished is given a HTTPRequest and HTTPResponse object and instantiates NegotiationResult.

    Is there anyway you can add the HttpResponse object from the negotiate endpoint as a variable to NegotiationResult? This would be very helpful for error handling.

    Thanks in advance!
     
  4. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @Afroman

    How do you authenticate? What IAuthenticationProvider implementation do you use? How do you get the access token?
     
  5. Afroman

    Afroman

    Joined:
    Aug 17, 2013
    Posts:
    43
    Hello @BestHTTP

    Thanks for your prompt response.

    I apologize for the confusion, I get the 401 error when connecting to the SignalR server NOT the /negotiate endpoint. I'm using Azure and the url looks like this (same response from previous post):
    https://MY_SERVICE.service.signalr.net/client/negotiate?hub=HUB_NAME&negotiateVersion=1

    I use a custom header IAuthenticationProvider. (It's the same one I that was in the HTTP/2 repo).
    The IAuthenticationProvider works fine, I deliberately let the access token expire by making the lifetime 1 minute on the server.

    I get the SignalR access token from a /negotiate endpoint.
     
  6. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    I hava a php script which sends back a merged file of requested files in a post.

    It works just fine with the UnityWebRequest approach but has some kinda encoding issue when receiving the data with HTTPRequest.

    The file being received is not binary compatible with the original on the server and I have tried changing filenames extension from .tex .bytes .bin without luck. The number of bytes received is correct though but its somehow encoded wrongly. It does correctly download with the unity web request call on post.

    Need help on this ?
     
  7. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @GXMark

    Could you send a repro-project? Without actually seeing what's going on, i don't think i can help in this case.
     
  8. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    In fact I noticed any binary file I put on my web server using normal request or request/post downloads causes non binary compatible with my original file I uploaded to the server.

    I think it might be some kinda mime file encoding issue or Content Header needs to be set on the code.

    If i'm downloading a binary file xxx.bytes from my web server is there any special Content Header configuration I need from HTTPRequest?

    I'm using WAMP server happens both locally and from remote server

    I tried application/octet-stream without success

    UnityWebRequest www = UnityWebRequest.Post("http://www.my-server.com/myform", formData); style downloads binary compatible so must be some kinda encoding

    Also I noticed that your streaming example downloads the data but never does a binary comparison check against its original so maybe there is a bug
     
    Last edited: Jan 12, 2020
  9. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    Ok I found what I did. I had a OnDataDownloaded handler and was appending dataFragment to a byte buffer. This caused the issue. I simply now removed the handler and take it direct from the Response in OnFinish. I still don't know why I could not append these bytes together with blockcopy.
     
  10. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
  11. TriPawCat

    TriPawCat

    Joined:
    Nov 23, 2015
    Posts:
    8
    Hi, we are using this version: 1.10.6 (2018.05.20)
    and still get the same problem.
     
  12. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @TriPawCat

    Could you send a full log? Also please note that the 1.x line is got deprecated and there's no support for it anymore.
     
  13. zTrojan

    zTrojan

    Joined:
    Feb 15, 2013
    Posts:
    14
    @BestHTTP
    Hi! Do you have plans for cacheable range responses?
     
  14. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @zTrojan

    Not in the near future. What would be your use-case?
     
  15. zTrojan

    zTrojan

    Joined:
    Feb 15, 2013
    Posts:
    14
    To resume Asset Bundle downloading if lost connection and load that bundle completely from cache in the future.
     
  16. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    218
    Hi, i noticed the changelog has 2.0.4 on the website, do you have an ETA when this will be packaged up for the asset store? thnx
     
  17. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @zTrojan

    If your bundles are large, you can do something like the resumable download sample.
     
  18. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @KB73

    Yep, want to push it to review today but it can be a few days until it goes live. If you want I can send a download link.
     
    KB73 likes this.
  19. zTrojan

    zTrojan

    Joined:
    Feb 15, 2013
    Posts:
    14
    Thank you for the reply.
    I saw that sample.
    My bundle is about 100MB size.
    After resuming I see that file at the cache isn't updating anymore.
    What to do after restarting the app? Download the bundle from the network again?
     
    Last edited: Jan 21, 2020
  20. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @zTrojan

    You can save the downloaded fragments to a file, send out a range request next time if it's not complete and append to the existing file.
     
  21. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    218
    All good, we can hang fire till the official release, much appreciated.
     
  22. Jim_Zee_King

    Jim_Zee_King

    Joined:
    Mar 10, 2014
    Posts:
    3
    @BestHTTP

    Hello! My job wanted me to start working on an old unity project that and fromer worker started like four years ago.
    The problem is that the assets they have is BestHTTP 1.9.4.

    I am restarting the project from scratch and am using unity 2019.2.1f1. I managed to correct the error when upgrading the old api (by unity automatic upgrade).


    Now my nodejs server will show when unity client is connected to it (logged in the console) and can also emit an event and unity client will receive the event and the data correctly

    But if i emit from the c# script to the server, nothing reaches the nodejs server. Do you have any idea what could cause this?

    I have the client script and server script as attachement in this message

    Many thanks!

    PS: I know i should update to latest version but the asset was bought with an account we do not have anymore. (Employee got sacked)
     

    Attached Files:

  23. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @Jim_Zee_King

    1.9.4 is very old, if you trying to use it with a recent socket.io version it's highly possible that they are incopatible. If you enable private messages to your profile (or you can drop a mail to my email address) i can send a download link to the last 1.x version. Although, 1.x is deprecated now, i would recommend to use the new v2.
     
  24. Jim_Zee_King

    Jim_Zee_King

    Joined:
    Mar 10, 2014
    Posts:
    3
    @BestHTTP

    Man you rock! I downgraded my socket.io version and it now works!
    No need to send me a download link (thanks you though) as ill make a prototype and then will tell my work to buy the new 2.0 version.

    Many thanks
     
  25. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    Having issues at runtime with HTTP Best in that it says connection refused when I try to download a file. When its run from the editor its fine.


    [637156530007423234] Ex [HTTPConnection]: Connector.Connect - Message: 1: Connection refused at BestHTTP.PlatformSupport.TcpClient.General.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, System.Int32 port) [0x000d4] in <252209b786af41088d1c64f609f6a46e>:0
    at BestHTTP.PlatformSupport.TcpClient.General.TcpClient.Connect (System.String hostname, System.Int32 port) [0x00052] in <252209b786af41088d1c64f609f6a46e>:0
    at BestHTTP.Connections.TCPConnector.Connect (BestHTTP.HTTPRequest request) [0x00178] in <252209b786af41088d1c64f609f6a46e>:0
    at BestHTTP.Connections.HTTPConnection.ThreadFunc () [0x00055] in <252209b786af41088d1c64f609f6a46e>:0 StackTrace: at BestHTTP.PlatformSupport.TcpClient.General.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, System.Int32 port) [0x000d4] in <252209b786af41088d1c64f609f6a46e>:0
    at BestHTTP.PlatformSupport.TcpClient.General.TcpClient.Connect (System.String hostname, System.Int32 port) [0x00052] in <252209b786af41088d1c64f609f6a46e>:0
    at BestHTTP.Connections.TCPConnector.Connect (BestHTTP.HTTPRequest request) [0x00178] in <252209b786af41088d1c64f609f6a46e>:0
    at BestHTTP.Connections.HTTPConnection.ThreadFunc () [0x00055] in <252209b786af41088d1c64f609f6a46e>:0
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
    Package Request Connection Timed Out!
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
     
    Last edited: Jan 26, 2020
  26. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423

    Update

    Its creating a localhost connection in runtime why is that ?

    [637156552406654172] I [RequestEventHelper]: Processing request event: [RequestEventInfo SourceRequest: http://localhost/filerequestor.php, Event: StateChange, State: Processing, Progress: 0, ProgressLength: 0, Data: 0]
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)
     
  27. Poinball

    Poinball

    Joined:
    Feb 23, 2016
    Posts:
    28
    @BestHTTP
    Hi ,

    With Socket.io and Your package,
    Is it possible to declare variable when we emit and receive ?
    Here is an Exemple of what i'm trying to explain.
    the data can send and read the .reason that have been created on the emit.
     
  28. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @GXMark

    Please record a full log and send over to me, i might be able to say more if i can see more.
     
  29. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @Poinball

    You can do the same with the plugin like this:
    Code (CSharp):
    1. Manager = new SocketManager(new Uri(address));
    2. Manager.Encoder = new SocketIO.JsonEncoders.LitJsonEncoder();
    3.  
    4. Manager.Socket.On(SocketIOEventTypes.Connect, (s, p, a) =>
    5. {
    6.     Manager.Socket.Emit("happy", new
    7.     {
    8.         reason = "its my birthday"
    9.     });
    10. });
    11.  
    12. Manager.Socket.On("serverMsg", (s, p, args) =>
    13. {
    14.     var data = args[0] as Dictionary<string, object>;
    15.  
    16.     Debug.Log(data["msg"]);
    17. });
     
  30. unadamlar

    unadamlar

    Joined:
    Jul 7, 2015
    Posts:
    10
    Hello, the connection drops when the game is paused. For example, when the user is watching an ad, after the ad is closed the connection is lost. But the event I wrote in Connection.OnClosed is not triggered. How can I solve this?
     
  31. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @unadamlar

    Sent a new pacakge in private, if OnClosed still not called, please capture a full log and send it to me.
     
  32. Poinball

    Poinball

    Joined:
    Feb 23, 2016
    Posts:
    28
    The Emit doesnt work, I got this error

    Code (CSharp):
    1. [637157085721639955] Ex [EventDescriptor]: Call - Message: 1: Encoding the arguments to JSON failed!   at BestHTTP.SocketIO.Socket.Emit (System.String eventName, BestHTTP.SocketIO.Events.SocketIOAckCallback callback, System.Object[] args) [0x0015c] in C:\Users\poinb\Desktop\UnityWebGL\WebGL\Assets\Best HTTP\Source\SocketIO\Socket.cs:194
    2.   at BestHTTP.SocketIO.Socket.Emit (System.String eventName, System.Object[] args) [0x00001] in C:\Users\poinb\Desktop\UnityWebGL\WebGL\Assets\Best HTTP\Source\SocketIO\Socket.cs:138
    3.   at PlayerManager.<Start>b__3_0 (BestHTTP.SocketIO.Socket s, BestHTTP.SocketIO.Packet p, System.Object[] a) [0x00001] in C:\Users\poinb\Desktop\UnityWebGL\WebGL\Assets\PlayerManager.cs:20
    4.   at BestHTTP.SocketIO.Events.EventDescriptor.Call (BestHTTP.SocketIO.Socket socket, BestHTTP.SocketIO.Packet packet, System.Object[] args) [0x00062] in C:\Users\poinb\Desktop\UnityWebGL\WebGL\Assets\Best HTTP\Source\SocketIO\Events\EventDescriptor.cs:74   StackTrace:   at BestHTTP.SocketIO.Socket.Emit (System.String eventName, BestHTTP.SocketIO.Events.SocketIOAckCallback callback, System.Object[] args) [0x0015c] in C:\Users\poinb\Desktop\UnityWebGL\WebGL\Assets\Best HTTP\Source\SocketIO\Socket.cs:194
    5.   at BestHTTP.SocketIO.Socket.Emit (System.String eventName, System.Object[] args) [0x00001] in C:\Users\poinb\Desktop\UnityWebGL\WebGL\Assets\Best HTTP\Source\SocketIO\Socket.cs:138
    6.   at PlayerManager.<Start>b__3_0 (BestHTTP.SocketIO.Socket s, BestHTTP.SocketIO.Packet p, System.Object[] a) [0x00001] in C:\Users\poinb\Desktop\UnityWebGL\WebGL\Assets\PlayerManager.cs:20
    7.   at BestHTTP.SocketIO.Events.EventDescriptor.Call (BestHTTP.SocketIO.Socket socket, BestHTTP.SocketIO.Packet packet, System.Object[] args) [0x00062] in C:\Users\poinb\Desktop\UnityWebGL\WebGL\Assets\Best HTTP\Source\SocketIO\Events\EventDescriptor.cs:74
    8. UnityEngine.Debug:LogError(Object)
    9. BestHTTP.Logger.DefaultLogger:Exception(String, String, Exception) (at Assets/Best HTTP/Source/Logger/DefaultLogger.cs:111)
    10. BestHTTP.SocketIO.Events.EventDescriptor:Call(Socket, Packet, Object[]) (at Assets/Best HTTP/Source/SocketIO/Events/EventDescriptor.cs:83)
    11. BestHTTP.SocketIO.Events.EventTable:Call(String, Packet, Object[]) (at Assets/Best HTTP/Source/SocketIO/Events/EventTable.cs:84)
    12. BestHTTP.SocketIO.Events.EventTable:Call(Packet) (at Assets/Best HTTP/Source/SocketIO/Events/EventTable.cs:113)
    13. BestHTTP.SocketIO.Socket:BestHTTP.SocketIO.ISocket.OnPacket(Packet) (at Assets/Best HTTP/Source/SocketIO/Socket.cs:422)
    14. BestHTTP.SocketIO.SocketManager:BestHTTP.SocketIO.IManager.OnPacket(Packet) (at Assets/Best HTTP/Source/SocketIO/SocketManager.cs:539)
    15. BestHTTP.SocketIO.Transports.PollingTransport:OnPacket(Packet) (at Assets/Best HTTP/Source/SocketIO/Transports/PollingTransport.cs:334)
    16. BestHTTP.SocketIO.Transports.PollingTransport:ParseResponse(HTTPResponse) (at Assets/Best HTTP/Source/SocketIO/Transports/PollingTransport.cs:436)
    17. BestHTTP.SocketIO.Transports.PollingTransport:OnRequestFinished(HTTPRequest, HTTPResponse) (at Assets/Best HTTP/Source/SocketIO/Transports/PollingTransport.cs:187)
    18. BestHTTP.Core.RequestEventHelper:HandleRequestStateChange(RequestEventInfo) (at Assets/Best HTTP/Source/Core/RequestEvents.cs:268)
    19. BestHTTP.Core.RequestEventHelper:ProcessQueue() (at Assets/Best HTTP/Source/Core/RequestEvents.cs:220)
    20. BestHTTP.HTTPManager:OnUpdate() (at Assets/Best HTTP/Source/HTTPManager.cs:350)
    21. BestHTTP.HTTPUpdateDelegator:Update() (at Assets/Best HTTP/Source/HTTPUpdateDelegator.cs:165)
    22.  
    But the On is reveiving the Hello, So that part work.
     
  33. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @Poinball

    Do you used the LitJson encoder (second line of my code)? The default one can't encode anonymous types.
     
  34. Poinball

    Poinball

    Joined:
    Feb 23, 2016
    Posts:
    28
    Ahh Thanks ! It work now :)
     
  35. wicea

    wicea

    Joined:
    Jan 23, 2016
    Posts:
    10
    @BestHTTP Hi. Today I detected same problem, but currently cannot reproduce it. Is it known issue? Are any fix available?


    Code (JavaScript):
    1. 01-28 14:41:32.757 15841 15906 I Unity   : ~~~> [POST] https://...
    2. 01-28 14:41:32.757 15841 15906 I Unity   : RequestsManager:Send(GameRequest)
    3. 01-28 14:41:32.757 15841 15906 I Unity   :
    4. 01-28 14:41:32.757 15841 15906 I Unity   : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 48)
    5. 01-28 14:41:32.770 15841 15906 I Unity   :
    6. 01-28 14:41:32.973 15841 23402 E Unity   : [637158192929189990] Ex [HTTP2Stream]: [2117] ProcessIncomingFrames - Message: 1: Index was out of range. Must be non-negative and less than the size of the collection.
    7. 01-28 14:41:32.973 15841 23402 E Unity   : Parameter name: index   at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00000] in <00000000000000000000000000000000>:0
    8. 01-28 14:41:32.973 15841 23402 E Unity   :   at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00000] in <00000000000000000000000000000000>:0
    9. 01-28 14:41:32.973 15841 23402 E Unity   :   at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00000] in <00000000000000000000000000000000>:0
    10. 01-28 14:41:32.973 15841 23402 E Unity   :   at BestHTTP.Connections.HTTP2.HeaderTable.GetKey (System.UInt32 index) [0x00000] in <00000000000000000000000000000000>:0
    11. 01-28 14:41:32.973 15841 23402 E Unity   :   at BestHTTP.Connections.HTTP2.HPACKEncoder.ReadLiteralHeaderFieldWithIncrementalIndexing_IndexedName (System.Byte firstByte, System.IO.Stream stream) [0x00000] in <00000000000000000000000000000000>:0
    12. 01-28 14:41:32.973 15841 23402 E Unity   :   at BestHTTP.Connection
    13. 01-28 14:41:33.102 15841 15906 I Unity   : <~~~ [POST] https://...
    14. 01-28 14:41:33.102 15841 15906 I Unity   : RequestsManager:OnRequestFinished(HTTPRequest, HTTPResponse)
    15. 01-28 14:41:33.102 15841 15906 I Unity   : BestHTTP.OnRequestFinishedDelegate:Invoke(HTTPRequest, HTTPResponse)
    16. 01-28 14:41:33.102 15841 15906 I Unity   : BestHTTP.Core.RequestEventHelper:HandleRequestStateChange(RequestEventInfo)
    17. 01-28 14:41:33.102 15841 15906 I Unity   : BestHTTP.Core.RequestEventHelper:ProcessQueue()
    18. 01-28 14:41:33.102 15841 15906 I Unity   : BestHTTP.HTTPManager:OnUpdate()
    19. 01-28 14:41:33.102 15841 15906 I Unity   :
    20. 01-28 14:41:33.102 15841 15906 I Unity   : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 48)
    21. 01-28 14:41:33.102 15841 15906 I Unity   :
    22. 01-28 14:41:33.118 15841 15906 I Unity   : resp.DataAsText:
    23. 01-28 14:41:33.118 15841 15906 I Unity   : RequestsManager:OnRequestFinished(HTTPRequest, HTTPResponse)
    24. 01-28 14:41:33.118 15841 15906 I Unity   : BestHTTP.OnRequestFinishedDelegate:Invoke(HTTPRequest, HTTPResponse)
    25. 01-28 14:41:33.118 15841 15906 I Unity   : BestHTTP.Core.RequestEventHelper:HandleRequestStateChange(RequestEventInfo)
    26. 01-28 14:41:33.118 15841 15906 I Unity   : BestHTTP.Core.RequestEventHelper:ProcessQueue()
    27. 01-28 14:41:33.118 15841 15906 I Unity   : BestHTTP.HTTPManager:OnUpdate()
     
  36. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @wicea

    Yep, it got fixed already, sent a download link in private.
     
  37. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    Apologies its was my code.
     
  38. mames

    mames

    Joined:
    May 3, 2016
    Posts:
    1
    Our application is often used in corporate environments operating behind a proxy. When attempting to auto detect proxy settings using .NET's HttpClient, we can auto detect the proxy information as follows:

    Code (CSharp):
    1. var systemProxy = WebRequest.GetSystemWebProxy() as WebProxy;
    2. systemProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
    The credentials class in the library requires a UserName and Password. However, the ICredentials instance returned by DefaultCredentials cannot be used to view the user name, password, or domain of the current security context. If queried it comes back null/empty... So we are unable to extract the DefaultNetworkCredentials username/password info to construct the correct Credential object.

    Is there anyway to use BestHttp using the default network credentials configured on the user's machine (typically their AD logins in most environments)? Is the only option to query the user to enter their AD login information?
     
  39. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    317
    Hi, I purchased Best HTTP in the hope of having a way of querying Firebase Realtime Database across all platforms using server-sent events for streaming data. (With UnityWebRequest, I can do all of that except the streaming bit on WebGL.)

    However, when trying to connect to an EventSource in the most naive way possible (taking your SimpleSample for EventSourcres and changing SimpleSample.cs:OnStartButton() to read:

    // Create the EventSource instance
    Uri uri = new Uri("https://fir-testdatabase-<REMOVED>.firebaseio.com/.json");

    this.eventSource = new EventSource(uri);

    I do not get any callbacks in the editor when modifying the database.

    I removed the actual database ID, just in case somebody reading this message wants to maliciously use a test database (??) but if I can PM you I'm happy to send it. It's really just a throw-away database, which I'm using the Web UI to modify and make sure my EventSources receive events. I have confirmed that a similar example written with UnityWebRequest works correctly on everything except WebGL.

    This is strange, since your own address on AzureWebSites for a time SSE seems to be working fine.

    Here is a Gist, which can be pasted into a script, showing the issue. It shows:
    - Best HTTP successfully downloads raw json from the DB in a get request.
    - UnityWebRequest being used to get data via SSE (although this fails on WebGL)
    - Best HTTP failing to open an EcventSource at the same URL.

    I'll PM you the address of the server so you can check. At the time of writing, the data returned (yes it really is test json) should be:

    {"1":"2","a":5}

    https://gist.github.com/ferretnt/4e3951276527cc8f8deb6c41e2c8d00e
     
    Last edited: Jan 31, 2020
  40. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    I have a question regarding using the HTTPResponse on finish event handler. When accessing the data response.Data i assign it to a job queue to be processed. Do i need to make a byte array copy of this data array before i recall send request for another file ? What is the live span of the response.Data ? Some like BlockCopy() assign to job queue call send request?
     
  41. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @mames

    Yep, accessing username and password just like that would be a security headache. Instead, it just indicates that you want to use the default proxy for your request then it authenticates using SSPI. The plugin doesn't support SSPI, so it can't use the proxy without actually knowing the username and password.
     
  42. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @ferretnt

    Thanks for the sample code and the url in private, i'm going to take a look on it as soon as i just can.
     
    Cromfeli and ferretnt like this.
  43. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @GXMark

    The plugin doesn't hold any reference to the Data after it calls the callback, so you are free to keep a reference. This is the theory at least, as there was a bug that i fixed, so i'm sending a download link in private.
     
    Cromfeli likes this.
  44. golfgamebook

    golfgamebook

    Joined:
    Nov 2, 2016
    Posts:
    1
    We are having the same issue. Could we have the updated version too?
     
  45. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    Just to let you know I did do the block copy and the problem was fixed. But thanks for the latest package i will give it a try.
     
  46. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    private download looks like sample selector missing lots of references
     
  47. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @GXMark

    Hmm, thanks, I will take a look on it.
     
  48. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    423
    Can you explain what the benefits of using Async-Await with HTTPRequest are ?

    I mean I have an array of n assets I want to request from a server.

    How would i download those binary raw data assets more efficiently using this Async approach ?

    Does it mean i can establish more than one connection with the server ?

    I thought the non Async method looked like a non block approach ?
     
  49. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,467
    @GXMark

    It uses the same code path and the same rules are applied (like max connections per server), but if you already using async-await it can be more streamlined. To process more than one download, you can use Task.WhenAll to wait for all the downloads.
     
  50. t-bergbauer

    t-bergbauer

    Joined:
    Mar 27, 2018
    Posts:
    3
    I get a IOException (sharing violation) when requesting a local excel file which is currently open.

    I localized the issue in the DefaultIOService.cs:

    case FileStreamModes.Open:
    return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);

    Changing the FileShare.Read to FileShare.ReadWrite would allow the stream to open while another process has a write handle on it.

    Is this intended behaviour? I am not sure if there could be any timing issues when accessing a file which might be written to.
     
unityunity