Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Best HTTP Released

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

  1. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,131
    Just messaged you. thanks
     
  2. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,131
    With your help I managed to resolve it, thank you - great support!
     
  3. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    Hi!

    I use WebSockets from the Best HTTP(Simple) library version 1.9.16 and I see a bit strange behavior, please correct me if I'm wrong. In case of network connection problems on a device there is an exception reported by OnErrorDesc callback:

    Request Finished with Error! Exception: Read failure at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
    12-11 11:26:37.157 32055 32142 I Unity : at System.IO.Stream.ReadByte () [0x00000] in <filename unknown>:0
    12-11 11:26:37.157 32055 32142 I Unity : at BestHTTP.WebSocket.Frames.WebSocketFrameReader.ReadByte (System.IO.Stream stream) [0x00000] in <filename unknown>:0
    12-11 11:26:37.157 32055 32142 I Unity : at BestHTTP.WebSocket.Frames.WebSocketFrameReader.Read (System.IO.Stream stream) [0x00000] in <filename unknown>:0
    12-11 11:26:37.157 32055 32142 I Unity : at BestHTTP.WebSocket.WebSocketResponse.ReceiveThreadFunc (System.Object param) [0x00000] in <filename unknown>:0

    Shouldn't that be rather an OnClose event?
     
  4. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    ...Or should I rather check in OnErrorDesc callback whether web socket is still open by IsOpen?
     
  5. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @pachash

    You can treat all OnError and OnErrorDesc events as OnClose events too, no need to check the IsOpen property. OnClosed will be called only when a successful protocol shutdown occurs (server or client initiated Close).
     
  6. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    Thanks! Still just to be on the safe side I'm going to check IsOpen property just in case if OnError or OnErrorDesc will be called for some other error conditions in the future.
     
  7. KeeLo

    KeeLo

    Joined:
    Nov 1, 2013
    Posts:
    76
    Hello BestHTTP!!! I've bought http pro today and i have an issue about websocket.Close();
    I have php server with websockets and after connecting i used websocket.Close(); but nothing happened i mean connecting doesn't close and after i unplayed unity editor i received "-An error occured: Unknown Error Status Code from Server: 101 and Message: Web Socket Protocol Handshake".... could you explain me why? Your example works fine but if write my adress, Close() also doesn't work! Thanks advance!

    P.S. I also noticed that OnClosed() did not work in my case!
     
    Last edited: Dec 13, 2016
  8. reddy36996

    reddy36996

    Joined:
    Jan 10, 2016
    Posts:
    19
    Thanks, I really appreciate sharing corrected version of the plugin with me. I just verified and it is working fine now.
    There is one more thing FYI, WebSocketSample.cs was throwing errors on webgl platform. I didn't go into more details since i didn't need examples so i just commented that script out
     
  9. thecodeviking

    thecodeviking

    Joined:
    Apr 9, 2013
    Posts:
    2
    Hello BestHTTP! I am having an issue with HTTP Streaming. If you mark an HTTPRequest for Abort using request.Abort(), it is never removed from the ActiveConnections list in the HTTPManager class. I had to change the handling of connections with an AbortRequested state in the OnUpdate() method to mark the connection for recycling. Otherwise, if you are starting and aborting requests that use streaming, you can do 4 just fine, but after that your request is immediately aborted, so it never runs. And the connection stats reveal 4 ActiveConnections. I can pull some code out into a sample if you want.
     
  10. abutt1

    abutt1

    Joined:
    Jan 24, 2014
    Posts:
    18
    Apologies if someone has mentioned this before,

    I've been testing using the HTTPRequest.UseStreaming flag and have seen an issue where:

    "request.State == HTTPRequestStates.Finished", but "request.Response.IsStreamingFinished" is still false.

    The request.Callback will fire the next frame and at that point request.Response.IsStreamingFinished will be true.

    Is that a bug? It seems odd to me that the request's state will be finished, but the response hasn't fully completed.

    It's a very rare occurrence, and I can work around it, but I wanted to see if anyone had an 'official' workaround.
     
  11. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @KeeLo

    It looks like the plugin is waiting for something and the websocket isn't open yet. Is it possible to send me a link that I can test?
     
  12. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @reddy36996 Can you send me the errors and version of your Unity? Thanks!
     
  13. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @thecodeviking
    I would be interested in the reproduction steps. Tried out with my streaming sample, but wasn't able to make the requests stuck calling Abort on them.
     
  14. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @abutt1 Got no report on an issue like this, but I will look for it, thanks!
     
  15. KeeLo

    KeeLo

    Joined:
    Nov 1, 2013
    Posts:
    76
    Yes of course i sent in private
     
  16. reddy36996

    reddy36996

    Joined:
    Jan 10, 2016
    Posts:
    19
    Capture.PNG
    I'm using Unity5.4.1
     
  17. abutt1

    abutt1

    Joined:
    Jan 24, 2014
    Posts:
    18
    I've been trying to create a repro but haven't been able to find out a consistent one yet. Just something to be aware of.
     
  18. phamtrongtai

    phamtrongtai

    Joined:
    Jan 15, 2015
    Posts:
    4
    Hi there,

    We're currently using best http (Best HTTP Pro Edition 1.9.16) for app to connect to Signalr server (version SignalR 2.2.1). If we use directly connecting between app and Signalr server, everything work just perfectly but when we put a Citrix between client app and Signalr server, it was fallbacked to longpolling along with the "503 service unavailable" error code. Now we stuck and don't know what's the exactly reason for that problem since the Citrix has only one option to enable Websocket support (as in picture). The information about Citrix version and our configuration are in the attached pictures. Please provide us an advice for this situation! We hope there would be some other customer did suffer this problem before.
    image (1).png image (2).png image.png
     
  19. jweinhartSW

    jweinhartSW

    Joined:
    Sep 30, 2016
    Posts:
    8
    We're hitting an issue with the latest asset store version where when using Socket.IO with a WebGL build, the connection is always closed after the timeout period. I tracked this back to the ping never getting sent out, which seems to be because HTTPManager's OnUpdate is never being called - but again, on PC/Desktop, this all works fine. Any ideas before I dig more into this?
     
  20. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
  21. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @abutt1 Thanks, I will still try to look for it.
     
  22. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @phamtrongtai

    To make sure I'm understanding it right:
    1.) The WebSocket transport fails with an unknown error.
    2.) Then as the plugin tries to downgrade to longpolling, it fails too, but with a known error (503).

    The first step would be to gather more information what's going on and what fails:
    1.) You can set logging level of the plugin to log out a lot of detail:
    Code (CSharp):
    1. BestHTTP.HTTPManager.Logger.Level = BestHTTP.Logger.Loglevels.All;
    2.) You can install Charles and set up the plugin to use it as a proxy:
    Code (CSharp):
    1. BestHTTP.HTTPManager.Proxy = new BestHTTP.HTTPProxy(new Uri("http://localhost:8888"), null, true);
    2.a) You must use plain HTTP. If you can't you must set up SSL Proxying in Charles (Proxy/SSL Proxy Settings... menu item):
    upload_2016-12-16_8-38-2.png
    2.b) You can export all the communications through the File/Save Session menu item.

    Then you can send me the logs/sessions so I can examine them.
     
    phamtrongtai likes this.
  23. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @jweinhartSW

    If you are receiving any callback than the OnUpdate surely called.
    On WebGL however, the plugin can't send out ping frames as browsers has no API for this (the underlying browser's implementation is used by the plugin).

    If your connection depends on ping, you may try out sending dummy messages manually.
     
  24. phamtrongtai

    phamtrongtai

    Joined:
    Jan 15, 2015
    Posts:
    4
    Hi,
    I send you data from Editor Log.
    1.) The WebSocket transport fails with an unknown error: 503 Service Unavailable ( but the webbrowser can connect OK).
    2.) Then as the plugin tries to downgrade to longpolling and the connect is OK, there are no problem.

    The problem is when we put a Citrix between client app and Signalr server webbrowser (Chrome) can connect to server using websocket by using signalr client javascript but the app use BestHTTP can not connect to server by using websocket.

    Thanks!
     

    Attached Files:

  25. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @phamtrongtai

    Unfortunately the logs can only confirm what we already know, but they can't answer why it's happening.
    Is it possible to get a test link in private?
     
  26. caiopellegrim

    caiopellegrim

    Joined:
    Dec 16, 2016
    Posts:
    4
    Hi!

    I'm considering to buy your package, before this I have some questions to be solved. Coud you help me please?

    Am I able to connect to https:// server, for example https://oururl:8080/websocket/home?x-auth-token=value

    My server has an Alpha-SSL cert, my backend is in java with spring framework and the server is TOMCAT.

    Thanks in advance
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @caiopellegrim

    For WebSocket it must be WSS:// instead of HTTPS://, but other than this it must work.
    Checked out https://alphassl.com/ with the plugin, and it's handled its certificate well.
    The backend shouldn't matter until we hit a bug, but I'm not aware of any it must be fine too.
     
  28. caiopellegrim

    caiopellegrim

    Joined:
    Dec 16, 2016
    Posts:
    4
    Yeah, I got the SockJS which translates the https to wss for me. I got the connection through ws://somenthing, however when I use SSL connections (wss://) it seems to fail, I got no error on the console aswell. Thats why I'm looking foward to buy your package.
    Although the money will not be provided by me, so I need to be sure that with your package I'll garantee the connection.
    Thanks for the quick reponse!
     
  29. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
  30. phamtrongtai

    phamtrongtai

    Joined:
    Jan 15, 2015
    Posts:
    4
    Hi,
    I have deployed my Citrix at: http://f1.fb-vn.com/, when use Chrome browser I can connect to Citrix by use websocket.
    I have use SimpleStreamingSample to test Signalr websocket connection ( change uri from: "https://besthttpsignalr.azurewebsites.net/streaming-connection" to: "http://f1.fb-vn.com/signalr"). When run code sample, I can not connect to server buy using websocket ( it fallback to server sent events).

    When I connect direct to server at http://f2.fb-vn.com/, it can connect by use websocket. So I think there are sothing wrong when connect through Citrix, but I don't know why when use Chrome I can connect use websocket protocol.

    Please help me!
     
  31. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @phamtrongtai

    Thanks for the link and all the additional information. Sent you a link to an updated package in private that should fix your issue.
     
  32. phamtrongtai

    phamtrongtai

    Joined:
    Jan 15, 2015
    Posts:
    4
    Hi,
    Now I can connect to citrix by use websocket :D.
    Thanks for your support!
     
  33. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @phamtrongtai

    Great! This fix will be included in the next release, you could update from the store as usual.
     
  34. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    Hi! That's me again. I use 1.9.16 simple version of the library. I send client error logs to our own server and by looking at them it seems like WebSocket.Send(..) may raise an exception. For example:

    WriteRecord (Byte type, System.Byte[] buf, Int32 offset, Int32 len)
    Org.BouncyCastle.Crypto.Tls.TlsProtocol.RaiseAlert (Byte alertLevel, Byte alertDescription, System.String message, System.Exception cause)
    Org.BouncyCastle.Crypto.Tls.TlsProtocol.FailWithError (Byte alertLevel, Byte alertDescription, System.String message, System.Exception cause)
    Org.BouncyCastle.Crypto.Tls.TlsProtocol.SafeWriteRecord (Byte type, System.Byte[] buf, Int32 offset, Int32 len)
    Org.BouncyCastle.Crypto.Tls.TlsProtocol.WriteData (System.Byte[] buf, Int32 offset, Int32 len)
    Org.BouncyCastle.Crypto.Tls.TlsStream.Write (System.Byte[] buf, Int32 off, Int32 len)
    BestHTTP.WebSocket.WebSocketResponse.Send()

    Is it OK? I thought rather OnError handler would be called.
     
    Last edited: Dec 21, 2016
  35. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @pachash

    Well, no, that's not OK. Send is a blocking function, if there's a problem it will not contribute to the WebSocket error/close logic. As you saw, it throws an exception, and the error callback is called when it detects that the tcp connection is closed.

    Well, that was the old behavior! :)
    I would send a link to an updated package, where Send became non-blocking, and any error will call the error callback properly. But private messages are disabled on your profile. :(
     
  36. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    Try now please
     
  37. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
  38. caiopellegrim

    caiopellegrim

    Joined:
    Dec 16, 2016
    Posts:
    4
    Hey BestHTTP it worked, I'd like to know if you accept paypal and if you send any receipt saying about rights to use or something like that.

    Thanks for everything!
     
  39. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @caiopellegrim

    The best way is to buy it in the Asset Store. You will receive notifications about new updates. You can also make your purchase with PayPal here.
     
  40. m-garin

    m-garin

    Joined:
    Sep 27, 2015
    Posts:
    4
    Please, send me the link to this fix too or fix this bug officially. I have same error
     

    Attached Files:

  41. xiaomaza

    xiaomaza

    Joined:
    Apr 4, 2015
    Posts:
    9
  42. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @xiaomaza

    You can increase the timeout of your requests globally:
    Code (CSharp):
    1. HTTPManager.RequestTimeout = TimeSpan.FromMinutes(2);
    or per-request:
    Code (CSharp):
    1. request.Timeout = TimeSpan.FromMinutes(2);
    The default value of these are 1 minute.
     
  43. xiaomaza

    xiaomaza

    Joined:
    Apr 4, 2015
    Posts:
    9
    @BestHTTP
    Thank you for your prompt reply,the last problem is solved. Now a new problem: When I downloaded the document is greater than 20M, there will be mistakes, as shown below, what is the reason?
    The compressed file link address: http://47.90.90.16:8080/AssetBundles/WebGL/1.0_1.1.7z
    Almost forgot to tell you that I released the Unity webGL platform.

    Error.jpg
     
    Last edited: Jan 4, 2017
  44. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @xiaomaza

    Used this setup and it's worked fine without any error using Microsoft Edge:
    Code (CSharp):
    1. Uri uri = new Uri("http://47.90.90.16:8080/AssetBundles/WebGL/1.0_1.1.7z");
    2.  
    3. HTTPRequest request = new HTTPRequest(uri, (req, resp) =>
    4. {
    5.     switch (req.State)
    6.     {
    7.         // The request finished without any problem.
    8.         case HTTPRequestStates.Finished:
    9.             if (resp.IsSuccess)
    10.             {
    11.                 Debug.Log("Request Finished Successfully! Response: '" + resp.DataAsText + "'");
    12.             }
    13.             else // Internal server error?
    14.                 Debug.LogWarning(string.Format("Request Finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
    15.                                                 resp.StatusCode,
    16.                                                 resp.Message,
    17.                                                 resp.DataAsText));
    18.             break;
    19.  
    20.         // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
    21.         case HTTPRequestStates.Error:
    22.             Debug.LogWarning("Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
    23.             break;
    24.  
    25.         // The request aborted, initiated by the user.
    26.         case HTTPRequestStates.Aborted:
    27.             Debug.LogWarning("Request Aborted!");
    28.             break;
    29.  
    30.         // Connecting to the server is timed out.
    31.         case HTTPRequestStates.ConnectionTimedOut:
    32.             Debug.LogError("Connection Timed Out!");
    33.             break;
    34.  
    35.         // The request didn't finished in the given time.
    36.         case HTTPRequestStates.TimedOut:
    37.             Debug.LogError("Processing the request Timed Out!");
    38.             break;
    39.     }
    40. });
    41.  
    42. request.Send();
    Can you share how you set up your request?
     
  45. cs_can

    cs_can

    Joined:
    Aug 15, 2013
    Posts:
    12
    Hi, I was told my app is rejected by Apple. The reason is my game does not support ipv6 networking. I am using BestHttp Pro and Unity 5.2.2. Any setup I should follow to make it?
     
  46. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
  47. shb

    shb

    Joined:
    Oct 7, 2012
    Posts:
    23
    Hi, I recently upgraded from version from 1.9.9 to the latest.
    My project is Unity5.5.0f3 ( the latest) uses socket.IO and works fine with 1.9.9,
    but after upgrade, it seems not working in WebGL build (works on Editor but not actual build)

    1. I can't connect to my server. When access manager.Socket , it just stops without any error.
    The logs after the line are not shown on console.


    SocketManager manager=new SocketManager(newUri(url),options);
    print("SocketManager:"+manager);
    Socket socketIO=manager.Socket;

    print("socketIO:"+socketIO); <-- I can't see this log from the console. the lines below this seems not getting executed.


    2.It might be a clue, right after I tried to access manager.Socket,
    I can see the Exception below.
    ObjectDisposedException: The object was used after being disposed.


    (Filename: currently not available on il2cpp Line: -1)


    I didn't change any code from my previous project after upgrading to the latest BESTHTTP.

    FYI,
    the Socket.IO sample seems also not working...
    I can see the same Exception when I try the sample on web browser after I build for WebGL.
    Of course sample works fine on Editor.

    any clue for me?
     
    Last edited: Jan 15, 2017
  48. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @shb

    Sent a link to an updated package that should fix this issue.
    Let me know how it works.
     
  49. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,197
    @BestHTTP If we're using a request to try to load a file locally or through a url, is there an equivalent of File.Exists() in your library to check if the file exists first before we load?
     
    Last edited: Jan 18, 2017
  50. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,505
    @Ben-BearFish

    The current file load implementation uses a plain FileStream, so File.Exists can be used.
    For urls, a HEAD request should return the very same response as it would for a GET, just without the body (so just the status line and the headers).
     
unityunity