Search Unity

  1. 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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Best HTTP Released

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

  1. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @littlstarsunny

    It shouldn't be a problem to run them parallel. If you use the default settings, the plugin will process maximum 4 requests per server (HTTPManager.MaxConnectionPerServer) and that shouldn't cause any problem.

    You may try to set the ConnectTimeout to TimeSpan.Zero, it will skip all timeout mechanism. In some cases it helped with connection problems...
     
  2. yangster

    yangster

    Joined:
    Apr 19, 2013
    Posts:
    2
    Hi BestHTTP:

    We downloaded BestHTTP Pro to use as a websocket client. We use tornado http://www.tornadoweb.org/en/stable/websocket.html on the server side.

    Whenever we call close connection from the server side, we would get an OnError or OnErrorDesc like below:

    Code (CSharp):
    1. Lobby connection errored: System.Exception: TCP Stream closed unexpectedly by the remote server
    2.   at BestHTTP.WebSocket.Frames.WebSocketFrameReader.ReadByte (System.IO.Stream stream) [0x00000] in <filename unknown>:0
    3.   at BestHTTP.WebSocket.Frames.WebSocketFrameReader.Read (System.IO.Stream stream) [0x00000] in <filename unknown>:0
    4.   at BestHTTP.WebSocket.WebSocketResponse.ReceiveThreadFunc (System.Object param) [0x00000] in <filename unknown>:0  Connection IsAlive: False
    Code (CSharp):
    1. Request Finished with Error! Exception: TCP Stream closed unexpectedly by the remote server  at BestHTTP.WebSocket.Frames.WebSocketFrameReader.ReadByte (System.IO.Stream stream) [0x00000] in <filename unknown>:0
    2.   at BestHTTP.WebSocket.Frames.WebSocketFrameReader.Read (System.IO.Stream stream) [0x00000] in <filename unknown>:0
    3.   at BestHTTP.WebSocket.WebSocketResponse.ReceiveThreadFunc (System.Object param) [0x00000] in <filename unknown>:0
    We need the OnClosed callback to fire because we need to retrieve the close code and reason.

    Can you help us?
     
  3. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @yangster

    Just found and fixed this issue yesterday! :)
    Sent a link to an updated package in private.
     
  4. HereDesign

    HereDesign

    Joined:
    Oct 25, 2015
    Posts:
    4
    Is there a simple working example of BestHTTP Pro with socket.IO? ideally a github repo with both unity client and server.

    I keep getting error message on even the simplest implementation... which i suppose I am doing incorrectly.
    Just simple connect/events at root would be enough.


    --

    Ex [PollingTransport]: ParseResponse - Message: 1: Array index is out of range. at BestHTTP.SocketIO.Transports.PollingTransport.ParseResponse (BestHTTP.HTTPResponse resp) [0x00054] in E:\Repos\VuforiaTest\ImageTests\Assets\Best HTTP (Pro)\BestHTTP\SocketIO\Transports\PollingTransport.cs:354 StackTrace: at BestHTTP.SocketIO.Transports.PollingTransport.ParseResponse (BestHTTP.HTTPResponse resp) [0x00054] in E:\Repos\VuforiaTest\ImageTests\Assets\Best HTTP (Pro)\BestHTTP\SocketIO\Transports\PollingTransport.cs:354
    UnityEngine.Debug:LogError(Object)
    BestHTTP.Logger.DefaultLogger:Exception(String, String, Exception) (at Assets/Best HTTP (Pro)/BestHTTP/Logger/DefaultLogger.cs:111)
    BestHTTP.SocketIO.Transports.PollingTransport:parseResponse(HTTPResponse) (at Assets/Best HTTP (Pro)/BestHTTP/SocketIO/Transports/PollingTransport.cs:407)
    BestHTTP.SocketIO.Transports.PollingTransport:OnRequestFinished(HTTPRequest, HTTPResponse) (at Assets/Best HTTP (Pro)/BestHTTP/SocketIO/Transports/PollingTransport.cs:187)
    BestHTTP.HTTPRequest:CallCallback() (at Assets/Best HTTP (Pro)/BestHTTP/HTTPRequest.cs:1251)
    BestHTTP.ConnectionBase:HandleCallback() (at Assets/Best HTTP (Pro)/BestHTTP/Connections/ConnectionBase.cs:171)
    BestHTTP.HTTPManager:OnUpdate() (at Assets/Best HTTP (Pro)/BestHTTP/HTTPManager.cs:593)
    BestHTTP.HTTPUpdateDelegator:Update() (at Assets/Best HTTP (Pro)/BestHTTP/HTTPUpdateDelegator.cs:163)
     
  5. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
  6. HereDesign

    HereDesign

    Joined:
    Oct 25, 2015
    Posts:
    4
    Thanks for the quick response, and on a Sunday no less! Sadly the chat example doesn't work for me, In a new project with only BEST HTTP.

    I get the same error, though the console logs a bunch of HTTP requests/responses. fails to connect and has only local echo
     
  7. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @HereDesign

    It looks they shut down the chat.socket.io domain and switched to socketio-chat.now.sh
    You can change the
    Code (CSharp):
    1. Manager = new SocketManager(new Uri("http://chat.socket.io/socket.io/"), options);
    line to
    Code (CSharp):
    1. Manager = new SocketManager(new Uri("https://socketio-chat.now.sh/socket.io/"), options);
    in the SocketIOChatExample.cs and it will work again.

    But, the main point is, that you have to append the /socket.io/ path to your url because by default the Socket.IO server binds to this path. Official clients (and maybe others too) will append this path, BestHTTP will try to guess less what the programmer wants.
     
  8. HereDesign

    HereDesign

    Joined:
    Oct 25, 2015
    Posts:
    4
    Thanks! Changing the domain does fix the example.

    But i guess I'm still missing something. If I run the socketIO chat server locally, it works fine. I am able to connect in browser using localhost:3000 or (127.0.0.1:3000)

    So then I thought that to connect the example chat in unity i should change the manager URI to read

    Manager = new SocketManager(new Uri("http://localhost:3000/socket.io/"), options);
    or
    Manager = new SocketManager(new Uri("http://127.0.0.1:3000/socket.io/"), options);

    but i get the same index out of range error. if i use that uri in the browser (localhost:3000/socket.io) i get the following response:

    {"code":0,"message":"Transport unknown"}

    if i leave off the port# i get a 404 error

    Thanks for your patience and assistance.

    -mark
     
  9. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @HereDesign

    It must be a 2.0.x server version, for a workaround you can connect straight with WebSocket:
    Code (CSharp):
    1. private void Connect() {
    2.     SocketOptions options = new SocketOptions();
    3.     options.ConnectWith = BestHTTP.SocketIO.Transports.TransportTypes.WebSocket;
    4.     manager = new SocketManager(new Uri("http://localhost:3000/socket.io/"), options);
    5.     manager.Socket.On(SocketIOEventTypes.Connect, OnConnected);
    6. }
    7.  
    8. private void OnConnected(Socket socket, Packet packet, object[] args) {
    9.     Debug.LogWarning("Socket Connected! " + socket.Id);
    10. }
    11.  
     
  10. HereDesign

    HereDesign

    Joined:
    Oct 25, 2015
    Posts:
    4
    Cool that connects now at least, but i guess server closes the socket after short period of inactivity. Perhaps i'll wait for a new version or try another route, my lack of knowledge in network programming makes troubleshooting workarounds problematic. appreciate the effort though.
     
  11. hoangphuc

    hoangphuc

    Joined:
    Mar 9, 2014
    Posts:
    2
    I bought Best HTTP so How can I use best HTTP Pro with socket.io v2. I can connect with raw Websocket but socket io client is not working. Please update Best HTTP right now :D
     
  12. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @hoangphuc

    There's a new, updated package with initial Socket.IO 2.x support. You can drop me a mail to besthttp@gmail.com and i will reply with a download link (alternately you can enable private messages to your profile here in the forum).
     
  13. melefans

    melefans

    Joined:
    Aug 1, 2016
    Posts:
    36
    @BestHTTP
    Some users in the wss start handshake will have some errors, 10% of users can not connect, their error log I can not get, and sometimes I will slow because the network error log: The authentication or decryption has failed.
    UseAlternateSSL = true, may it be helpful to me?
    My version is 1.9.5, or will it be helpful to upgrade the new version?
     
  14. phoenixian

    phoenixian

    Joined:
    Apr 27, 2017
    Posts:
    16
    is it possible to access the lower level socket manager object that contains the array of opened/active/closing etc websockets? so we dont have to manage another array/manager on top of it?
     
  15. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @melefans

    Since 1.9.10 (2016.03.14) UserAlternateSSL has a true value as default. I can highly recommend to try it out!
     
  16. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @phoenixian

    With the Pro version of the plugin you can change the HTTPManager's ActiveConnections to public visibility, but it will contain all active connections. An active connection has a HTTPRequest object assigned.

    I think it might be better to keep a higher level manager to track your websockets.
     
  17. Pasier

    Pasier

    Joined:
    Apr 11, 2013
    Posts:
    7
    I also have this "Ex [PollingTransport]: ParseResponse - Message: 1: Array index is out of range" error

    Can I get also this patch? Or is there a near release date for the fix? Thanks!
     
  18. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @Pasier

    Sent a download link in a private message.
     
    Pasier likes this.
  19. Petrinki

    Petrinki

    Joined:
    May 30, 2017
    Posts:
    1
    Hi, in my application a client certificate is required for connecting with the server.
    Actually, I'm using HTTPWebRequest for providing the certificate in the request.

    I would like to know if it's possible to do the same with BestHTTP.

    This is the code I'm using:

    Code (CSharp):
    1. // ....
    2. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    3.         request.ContentType = "application/x-www-form-urlencoded";
    4.         request.Method = method;
    5.         X509Certificate2 certificate = new X509Certificate2(certPath, certPassword);
    6.         request.ClientCertificates.Add(certificate);
    7.         HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    8. // ...
    Do I have the option to add my certificate also with BestHTTP?

    Regards
     
  20. waxx

    waxx

    Joined:
    Apr 1, 2013
    Posts:
    37
    I was wondering if there is any way in your SignalR client to hook up to an event of any method call from the hub. In your docs I see:


    // Register a server-callable function
    base.On("ClientFunction", ClientFunctionImplementation);

    I'd like to abstract hubs and your plugin and so I'd love to just get an event on any message received FROM the hub. Is there any way to do it with your plugin?

    Thanks.
     
  21. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @Petrinki

    The plugin uses Bouncy Castle as a bundled lib to handle SSL/TLS connections.
    You can implement an IClientCredentialsProvider and set it as the CustomClientCredentialsProvider for a HTTPRequest, but it's a little complicated. I think this would be the harder way.

    The plugin also capable to use the framework default SslStream by plipping a switch, but client credentials submission isn't routed to the surface through the HTTPRequest class. With a little coding it could be possible to route it, and it would be the easier way.
     
  22. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @waxx

    The Hub class has an OnMethodCall event that called before any function callback:
    Code (CSharp):
    1. public abstract class AbstractHub : Hub {
    2.   public AbstractHub(string name, BestHTTP.SignalR.Connection connection)
    3.     : base(name, connection) {
    4.     base.OnMethodCall += Hub_OnMethodCall;
    5.   }
    6.  
    7.   private void Hub_OnMethodCall(Hub hub, string method, params object[] args) {
    8.     Debug.Log("Server tries to call client function: " + method);
    9.   }
    10. }
    This will print out all function that the server tries to call on the client.
     
  23. mhernandez88

    mhernandez88

    Joined:
    Jul 20, 2016
    Posts:
    31
    @BestHTTP : Namespaces don't seem to be working with socket.io 2. Can you verify.
     
  24. mhernandez88

    mhernandez88

    Joined:
    Jul 20, 2016
    Posts:
    31
    Turns out I had to wait for the "connect" event before firing events.
     
  25. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @mhernandez88

    As a general rule it's best to wait for a successful connection. The plugin will store packets while it connects, but it will not check namespaces. So it's very possible that the server will not process those namespace packets that not connected yet.
     
  26. JonhWeine

    JonhWeine

    Joined:
    Jun 10, 2017
    Posts:
    3
    @BestHTTP

    I want to use WebSockets to download thousands of binary files with the Unity WebGL player with one live connection. I need this, since apparently Unity WebRequests do not support a keep alive connections, and creating a new connection for every file is simply too slow for production. I'm considering buying the pro version in order to make it as lean as possible.

    Would Best HTTP Pro help me? Is this an appropriate use for WebSockets, or is there some other way I can achieve the same functionality without using a web service? Could someone recommend what would be the best way to use a web service to dispatch thousands of binary files to my WebGL application? Should i write one myself in C# or is there a recommended platform i can purchase in order to save time and money.

    Thank you for your help. This looks like an absolutely amazing asset.
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @JonhWeine

    Under WebGL all connections are controlled by the underlying browser. Browsers usually try to keep the connection alive by sending a "Connection: Keep-Alive" header to the server, but the server can reject this request by sending a "Connection: Close" header in its response. In this case the client must not try to reuse the connection.
    So, first I would suggest to take an eye on your server's configuration, you may end up with much leaner and cheaper solution. :)

    On the other hand, using a WebSocket connection would a very good approach. Not just because to avoid reconnections, but it has a much (and i have to emphasize it: ) _much_ less overhead especially if you want to transfer thousands of files.
    While different browsers could define different message size limit, it's possible that you can do it with one message per file. It would greatly reduce the need for complexity.

    You can use my plugin for WebSockets too, and it has the same API for all platforms, you can write and test your code then you can build for WebGL without modifying it. (Although, as already noted, it must use the browser's implementation, you have to test on browsers too!)
     
  28. JonhWeine

    JonhWeine

    Joined:
    Jun 10, 2017
    Posts:
    3
    @BestHTTP
    Seems like WebSockets is the way to go. What does the server need to dispatch binary files on request. Are there examples provided in bestHTTP Pro?
     
  29. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @JonhWeine

    I don't know any examples, but I would send it in a binary message with some additional metadata.
     
  30. JonhWeine

    JonhWeine

    Joined:
    Jun 10, 2017
    Posts:
    3
    @BestHTTP

    I have noticed that my company firewall doesn't allow WebSocket connections since only the http port is allowed. Is it possible to reroute the connection to the http port? Or is this impossible in WebGL since the browser makes the connection?

    All our clients are behind some sort of company firewall, so it appears that I am forced to use a http connection if I can't get this resolved.

    The Unity WebReqest class doesn't allow any custom headers apparently. If I comprehend your documentation correctly I still need to make separate HTTPRequests to my files. The Keep-Alive header simply makes the browser not attempt any new connections if one is already made. How can I debug this to make sure that only one connection is made?

    Thank you very much for your help.
     
  31. CerberusInteractive-Morgan

    CerberusInteractive-Morgan

    Joined:
    Aug 25, 2016
    Posts:
    19
    Just wanted to mention this in case anyone else runs into this issue: if you are doing a post request with no data in the body, make sure to include the header "Content-Length" with a value of "0" or else you will get an error 411
     
  32. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @JonhWeine

    I don't think you can reroute your requests without an additional server. (However you may be add a proxy on your server and route the requests to the real web app based on some header values...)

    If you can go with the websocket one because of the firewall issues, you might try to bundle the files into one large and download it so. If you can prepare the download you might be able to use an AssetBundle, or if the downloads might change the server can zip them into one file and unzip it on the client?

    Anyway, I think the browser will support multiple requests in parallel even when it uses Keep-Alive. But browsers might have limits on the ongoing requests. (The plugin limits requests too, but you can control it through the HTTPManager.MaxConnectionPerServer property. It has a default value of 4 (concurrent requests per server)).
     
  33. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
  34. melefans

    melefans

    Joined:
    Aug 1, 2016
    Posts:
    36
    @BestHTTP
    HttpManager.MaxConnectionPerServer = 4.
    This parameter becomes larger, there will be those bad effects ?
     
  35. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @melefans

    MaxConnectionPerServer will control only the number of threads the plugin will use to process requests made to the same server.
    So, if you send out 10 requests to server1, by default it will process 4 requests, and when one finished will process the next.
     
  36. nloewen

    nloewen

    Joined:
    Apr 29, 2015
    Posts:
    5
    I am receiving the following error when creating EventSource connections in WebGL Builds:

    `EventSource cannot load <URL>. Redirect from '<URL>' to '<REDIRECT_URL>' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://127.0.0.1' is therefore not allowed access.`

    In order to fix this, I need to set the request's withCredentials parameter to false. It is currently hardcoded to true in BestHTTP.
     
    Last edited: Jun 19, 2017
  37. bogdan-hodorogea

    bogdan-hodorogea

    Joined:
    Nov 2, 2015
    Posts:
    8
    @BestHTTP
    Is there any way to set the ping interval and ping timeout on the BestHTTP.SocketIO.SocketManager class , or do we have to use the basic WebSocket class?
    We are looking for this functionality from the js socket.io:
    Code (JavaScript):
    1. var io = require('socket.io')(http, {'pingInterval': 2000, 'pingTimeout': 5000});
     
  38. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @nloewen

    Sent a new package in private.
     
  39. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @bogdan-hodorogea

    The socket.io server will send these values in the very first (handshake) message to the clients, and they will use these values.
     
  40. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    163
    Hey i am getting an error in WebGL trying to get a png image from cloudfront. When requesting from cloudfront we are getting the error ObjectDisposedException right after
    Code (CSharp):
    1. new HTTPRequest
    the image we are trying to get is https://dr8u6iu2x4v0s.cloudfront.ne...cc9d5c728f5/mugshots/Headshot-1a78eeca12e.png

    So then we tried to get the image from our local server (mapped to unity.blackoutrugby.com) to see if it was a CORS problem, and got a different error: https://www.dropbox.com/s/t8kqgkov4uk76sl/error.txt?dl=0

    This is the code we are using:
    Code (CSharp):
    1.  
    2.  
    3. var url = "https://dr8u6iu2x4v0s.cloudfront.net/players/b27f9601-0c29-41b8-8dfb-6cc9d5c728f5/mugshots/Headshot-1a78eeca12e.png";
    4.  
    5. HTTPManager.Logger.Level = BestHTTP.Logger.Loglevels.All;
    6.  
    7. new HTTPRequest(new Uri(url), (request, response) =>
    8. {
    9.     Texture2D tex2D = new Texture2D(1, 1); // texture constructor
    10.     tex2D.LoadImage(response.Data); // convert to texture 2d
    11.  
    12.     if (!imageMap.ContainsKey(url))
    13.         imageMap.Add(url, tex2D); // add to dictionary
    14.  
    15. }).Send();
    16.  
    The execution never reaches the call back response.
     
  41. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @Brogan89

    What version of the plugin are you using? It should be fixed by v1.9.17.
     
  42. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    163
    Doh! How embarrassing. It was the version. False alarm. It works fine now.
    Thanks @BestHTTP
     
  43. tritmt

    tritmt

    Joined:
    May 26, 2013
    Posts:
    3
    Hi @BestHTTP
    I have an issue with BestHTTP and proxy tools like Charles, Fiddler...
    BestHTTP version : 1.9.9

    when I call to request the Http with BestHTTP, I can't see anything via proxy Tools Charles, Fiddler.

    I try to call request with class WWW, I saw the request and respond normally.
    I not sure what wrong in the case.
    I tried the sample built-in BestHTTP 1.9.9, But I receive same an issue (not thing show via proxy Tools Charles, Fiddler)

    Can you help me in this case?
     
  44. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @tritmt

    You have to set up the plugin to to the proxy, it can't detect and use it automatically.
    You can set it up globally:
    Code (CSharp):
    1. BestHTTP.HTTPManager.Proxy = new BestHTTP.HTTPProxy(new Uri("http://localhost:8888"), null, true);
    Or per-request using the request's Proxy property and assigning the same HTTPProxy object.
     
  45. vandelpal

    vandelpal

    Joined:
    Aug 20, 2015
    Posts:
    1
    We call resp.GetFirstHeaderValue("content-length");
    and for some users catch Exception
    System.NullReferenceException Object reference not set to an instance of an object

    Probably Headers has this header, but List<string> values is null. Please fix it, thanks:)
    version plugin 1.9.15
     
  46. tritmt

    tritmt

    Joined:
    May 26, 2013
    Posts:
    3
    Thanks @BestHTTP
    Amazing when I set global proxy like your comment. I can see request-respond via tool Charles.
     
  47. Steffen-ttc

    Steffen-ttc

    Joined:
    May 27, 2017
    Posts:
    4
    Hi @BestHTTP

    I have some issues using websockets on android with gear vr. Often we have to try to connect up to 25x before success.
    Code (CSharp):
    1.  
    2. // try every 3s to connect
    3. while (!connected)
    4.        {
    5.             if (webSocket == null)
    6.             {
    7.                 webSocket = new WebSocket(new Uri("ws://192.x.x.x:xxxx"));
    8.  
    9.                 // Subscribe to the WS events
    10.                /* [...] */
    11.  
    12.                 // Start connecting to the server
    13.                 webSocket.Open();
    14.                 yield return new WaitForSeconds(3.0f);
    15.  
    16.             } else
    17.             {
    18.                 webSocket.Close();
    19.                 webSocket = null;
    20.                 reconnectTry++;
    21.             }
    After a restart of the whole app, it works immediatly or after the first 3 connecting attempts. We have a webgl browser version with plain javascript where everything is working fine.

    Another problem is that it seems to be much slower than in the browser. From time to time there is something like an extra time lag: e.g. the OnBinaryReceived function is called every 40ms for 10-12 times. For the next call there is a delay of 150ms or bigger. Then the next one or two calls are inbetween a very few milliseconds.After that everything is ok for the next 10-12 calls...

    I am using the Pro version from the asset store v.1.10.0.

    Do you have any ideas? Could this be a restriction of Android (Samsung S7 with Android 7.0)
     
  48. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @vandelpal

    The server is free to exclude the Content-Length header, or send the content with chunked encoding.
    So, when the GetFirstHeaderValue returns with null, that's because the server doesn't sent it.
     
  49. Yaukey

    Yaukey

    Joined:
    Feb 25, 2013
    Posts:
    8
    Hi, @BestHTTP , I can not run the example when i build the example under webgl platform, the browser popup a message box: "Uncaught ReferenceError: ws is not defined". It seems that there is something wrong with the websocket jslib plugin. Am i doing something wrong? How can id fix it. Thx!
    websocket_error_2017628-160455.jpg

    (I am developing a webgl online game, can i use besthttp for websocket?
     
  50. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,492
    @Steffen-ttc

    For the connection, and for all the low level code the plugin uses the Socket api of the mono framework.
    It might worth to take a try on disabling connection timeouts, in some cases it's fixed a weird issue.
    Code (CSharp):
    1. HTTPManager.ConnectTimeout = TimeSpan.Zero;
    Other than this, I don't know what it could be, as I wrote socket connection is done by the framework/system.

    For the overall performance, you can read one of my previous post here.

    You can try out the mentioned TryToMinimizeTCPLatency:
    Code (CSharp):
    1. webSocket.InternalRequest.TryToMinimizeTCPLatency = true;
     
unityunity