Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Best HTTP Released

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

  1. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    Hi again,

    I did what you asked for,

    In server.js at line 303 https://github.com/socketio/engine.io/blob/master/lib/server.js#L303

    var transport = new transports[transportName](req); //This line throws error of bad_request.

    With other socket.io js clients can pass through this but not with besthttp :(

    This is the req variable provided and failed, it is too long therefore i added into google drive.

    https://docs.google.com/document/d/1wrYOUazKcGuRSC-SlmY4K4x5PQ5DgBLjhOZPJ9UbOUM/

    This is the req of that line inside O2 UK with socket.io js client which is working..

    https://docs.google.com/document/d/1WDcxoRgH95rrgBy6DmPqwjPIt-4-FI1NlLxyozmuz04/

    Also this is the req of that line outside O2 UK with besthttp which is working..

    https://docs.google.com/document/d/18e46hOxg0uHjou9wgVCwCVCpVSQl8M2SqYuxE51qr2Q/

    So do you have any idea about what's going on ?
     
    Last edited: Nov 21, 2018
  2. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @cemozturk

    Are you sure you are using the latest version (v1.10.10) of the plugin?
    I changed the connection header's value to include only the "upgrade" value, but in your log it's still the old "keep-alive, upgrade".
     
  3. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    Yes i'm, this is the latest version of your library that i downloaded from asset store.

    Specifically, i'm using Precompiled package of your plugin.
     
  4. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @cemozturk

    The Basic version is deprecated since April and its last version is about one year old (v1.10.3). You should be able to upgrade to the Pro version for free in the asset store.
     
  5. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    I was using Precompiled package of Best HTTP Pro just for compile time issues.

    Ok i'm trying the full package version.
     
  6. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @cemozturk

    There's a RelaseNotes.txt in the plugins folder (\Best HTTP (Pro)\ in case of the pro version) and the first line is your current version.
    If you have 1.10.10, you can still try to reimport the package.
    You can also check \Best HTTP (Pro)\BestHTTP\WebSocket\Websocket.cs at line 243. Setting the "Connection" header must look like this:
    Code (CSharp):
    1. // The request MUST contain a |Connection| header field whose value MUST include the "Upgrade" token.
    2. InternalRequest.SetHeader("Connection", "Upgrade");
     
  7. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    Wow! There is something going on here..

    1. I deleted the plugin from my project.
    2. I downloaded the latest plugin from
    https://assetstore.unity.com/packages/tools/network/best-http-10872

    The release txt says it's

    Upgrading to 1.9.x:
    In v1.9.0 all DLL dependencies are removed, and some of the files from the source too. So a clean install is advised: Before you install v1.9.x you have to remove the /Assets/Best HTTP (Pro)/ folder and TcpClientImplementation.dll from the /Assets/Plugins/, /Assets/Plugins/Metro and /Assets/Plugins/WP8 folders.

    1.10.3 (2017.11.11)

    What am i doing wrong ?
     
  8. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @cemozturk

    Another note is, as I suspected originally, O2 modifies the request. The main problem is, that it removes the "Upgrade" value from the "Connection" header when in you case, there are more than one value.
    But, you can see, that they are adding two additional headers too: "x-gateway" and "x-forwarded-for". I guess that you are not using HTTPS/WSS for your server, but, in this case it would be advised as the ISP couldn't alter the request as the communication would be encrypted.
     
  9. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @cemozturk

    Unity might not downloaded the new version at all. I can remember i read about issues just like this years ago. I will send a link in private.
     
  10. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    YES IT WORKS..

    The problem is my unity caching has gone bad..

    I deleted the cache folder and restart the unity and re install the package from store.

    And it connects from O2 right now..

    Thank you,

    You're a great provider :)
     
    Cromfeli likes this.
  11. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @cemozturk

    Super! You can let others about it by writing a little review in the asset store. :)
     
    Cromfeli likes this.
  12. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    Of course :) After the store updates :)
     
    Cromfeli likes this.
  13. gamerko

    gamerko

    Joined:
    Sep 26, 2018
    Posts:
    8
    @BestHTTP

    Hello..

    1.
    If the server disconnects, the OnClosed callback is not called. In this case, is it normal that only the OnError callback is called?


    2.
    Within the Unity OnApplicationQuit function, call Close.
    At this time, an error occurs like the screen. Is there a solution to this problem?


    Code (CSharp):
    1.  
    2.         protected override void OnDestroy()
    3.         {          
    4.             if (_mode != null)
    5.             {
    6.                 _mode.Disconnect();
    7.             }
    8.  
    9.             base.OnDestroy();
    10.         }
    11.  
    12.         private void OnApplicationQuit()
    13.         {
    14.             if (_mode != null)
    15.             {
    16.                 _mode.Disconnect();
    17.             }
    18.         }
     

    Attached Files:

  14. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @gamerko

    1.) When an error occurs, only the OnError/OnErrorDesc callback is called.
    2.) I think you should call close only from the OnDestroy event.
     
  15. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    426
    Hi @BestHTTP Looks a very promising asset, great reviews and your level of support is highly complemented. Looking at this forum I can see why. So I thought I might take advantage of the current sale before it ends...

    Can I ask whether you have any demos for downloading asset bundles?

    I've been using another asset for 'big file downloads' and although it appears to work fine for me and most other people, I'm getting a bunch of reports from some players that their downloads never complete. I'm no server techie, or http guru, I'm just hoping for a robust plug and play solution to easily download asset bundles, resume downloads if interrupted or restart if the download is somehow broken...

    Any chance that BestHttp can do all that for me? :D
     
  16. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    jeromeWork likes this.
  17. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    426
    For any potential customers... such an amazing response from this dev, I just had to purchase the asset. Outstanding support.
     
    Cromfeli and BestHTTP like this.
  18. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    @BestHTTP
    I'm also trying to upgrade my version of the library and for some reason Unity installer downloads 1.9.16 version not the latest one :(
     
  19. BestHTTP

    BestHTTP

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

    Sent a private message. I would recommend to delete your unity asset store cache, or find another way to solve it to make it work for future updates.
     
    pachash likes this.
  20. gamerko

    gamerko

    Joined:
    Sep 26, 2018
    Posts:
    8
    @BestHTTP

    Thank you for your question.

    There is another question.

    Does BestHTTP have a socket identifier?

    If you implement a function such as Logout, the same callback as OnError is being called on a previously connected socket, and you want to control the callback with the identifier of the socket.
     
  21. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @gamerko

    The websocket has no identifier, but on non-webgl platforms, you can assign one:
    Code (CSharp):
    1. webSocket = new WebSocket(new Uri(address));
    2. #if !UNITY_WEBGL || UNITY_EDITOR
    3. webSocket.InternalRequest.Tag = 123;
    4. #endif
    5.  
    You can access the same way InternlRequest.Tag in an event handler:
    Code (CSharp):
    1. private void OnErrorDesc(WebSocket webSocket, string reason)
    2. {
    3. #if !UNITY_WEBGL || UNITY_EDITOR
    4.     int uid = (int)webSocket.InternalRequest.Tag;
    5. #endif
    6. }
    7.  
     
  22. mattking

    mattking

    Joined:
    Jun 25, 2013
    Posts:
    2
    @BestHTTP

    We're finding that that in Unity 2018.2, with .NET 4.x on il2cpp on Android and iOS that reading headers is very slow. We've determined this to be an issue related to .NET's SslStream. I've opened a ticket with Unity and their response to this SslStream issue was that it was being used incorrectly. Unity's response:


    The performance issue occurs in the ReadTo method of HTTPResponse.cs:
    Code (CSharp):
    1.  
    2. public static string ReadTo(Stream stream, byte blocker1, byte blocker2)
    3. {
    4.     using (var ms = new MemoryStream())
    5.     {
    6.         int ch = stream.ReadByte();
    7.         while (ch != blocker1 && ch != blocker2 && ch != -1)
    8.         {
    9.             ms.WriteByte((byte)ch);
    10.             ch = stream.ReadByte();
    11.         }
    12.  
    13.         return ms.ToArray().AsciiToString().Trim();
    14.     }
    15. }
    16.  

    The implementation of ReadByte on the Stream type is not buffered behind the scenes, so it literally reads one byte from the stream at a time. We've hit this issue before with Mono/Xamarin, and there is some discussion here:

    https://github.com/mono/mono/issues/7077

    It looks like it would be better for BestHTTP to do its own buffering.
    It looks like Unity is suggesting that you need to buffer the reading of that stream in order to increase performance. This issue does not exist in .NET 3.5, or if you use the Bouncy Castle implementation of SSL. Originally we were using SslStream as we found it to perform better than the Bouncy Castle implementation.

    If you'd like a test repro project I have one, but it would contain Best HTTP source so it would have to be sent privately.

    Thanks,

    Matt
     
  23. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @mattking

    The lack of buffering was an issue with BouncyCastle (and with plain text) too. Calling ReadByte is quite under-performing. Not to mention that my ReadTo functions generate a lot of string garbage.

    I already have version to fix these issues in my dev branch, although it's barely tested. If you interested i can package it up and send over to you.
     
    JoshPeterson likes this.
  24. tkumpumaki

    tkumpumaki

    Joined:
    Sep 26, 2018
    Posts:
    18
    There is some pretty badly implemented buffer allocation inside mono's TLS implementation. (At least when using HttpWebRequest, I think this may be same problem). Each read to TLS stream causes 16500 byte buffer reallocation, due to somedoby not bothering to reuse/clear same buffer if having same size. For now the only way to make the impact smaller is to try to read in as much as is available each time you call read. I have submitted a bug report to Unity #1084800. However it's actually mono's bad implementation and if it's going to get fixed is another thing.

     
  25. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @tkumpumaki

    Mono has a long history of issues handling SSL/TLS, that's one of the reasons I have to include BouncyCastle and use it as the default one even as it has its own issues too.
    I'm happy that the new scripting runtime comes with a newer TLS handler too, but BC have to remain in the plugin for years.
     
    Cromfeli likes this.
  26. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Also interested in doing the same thing, @BestHTTP can you send me details on that aswel.. also bought the asset, sale price :)
     
    Cromfeli likes this.
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @Player7

    The package already contains an AssetBundle download sample in \Best HTTP (Pro)\Examples\HTTP\AssetBundleSample.cs and a large file download one in \Best HTTP (Pro)\Examples\HTTP\LargeFileDownloadSample.cs.
     
  28. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    great I'll check it out, barely had the time to go through the cyber week sale purchases :D
     
  29. mattking

    mattking

    Joined:
    Jun 25, 2013
    Posts:
    2
    Please do. I'd like to test it out.
     
  30. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @mattking

    Sent an updated package in private.

    The main motivation was to improve a small set of functions - these are the ReadTo functions - and use the new buffer pool where it can trivially replace new byte[] allocations. ReadTo functions now creates only the final strings, and uses the new buffer pool to make it garbage free.

    As I mentioned, I also replaced a few new byte[] calls with buffer pools.
    One problem with a general memory pool, is that my plugin is just a lib, it can't keep its memory indefinitely. If an app uses a few requests when starts up, the plugin has no right to keep these buffers increasing the app overall memory usage.
    So, it will pool and reuse these buffers, but when a buffer isn't used for a specific time period, it will remove its reference to let the GC collect it.

    There are allocations that can't be pooled(like growing downloaded content), and there are other dependencies that also make garbage (decompression, encryption/decryption).
     
  31. AlexRyder

    AlexRyder

    Joined:
    Jul 3, 2017
    Posts:
    10
    Hello,
    Just wondering if there is maybe some way to fasten up simple https: post/get requests when using BestHTTP, especially when running them in a separate thread without the need of synchronization with Unity's thread?

    Here are 2 code snippets which I know are far from the best, but they're here for science and to put them in exact same conditions.

    Using Unity's WWW class:
    Code (CSharp):
    1. WWWForm form = new WWWForm();
    2. form.AddField(...);
    3. long time = _stopwatch.ElapsedMilliseconds;
    4. WWW www = new WWW(_requestUri, form);
    5. while (!www.isDone)
    6. {
    7.     _autoResetEvent.WaitOne(15);
    8. }
    9. time = _stopwatch.ElapsedMilliseconds - time;
    10. Debug.Log(time);
    Using BestHTTP:
    Code (CSharp):
    1. HTTPRequest request = new HTTPRequest(_requestUri, HTTPMethods.Post, false, null);
    2. request.AddField(...);
    3. request.DisableCache = true;
    4. long time = _stopwatch.ElapsedMilliseconds;
    5. request.Send();
    6. while (request.MoveNext())
    7. {
    8.     _autoResetEvent.WaitOne(15);
    9. }
    10. time = _stopwatch.ElapsedMilliseconds - time;
    11. Debug.Log(time);
    Comparing time for a bunch of requests for the same data I see that the WWW version usually takes about 700...800 ms, while BestHTTP needs 1100...1300 ms, which becomes really noticeable when the data needs to be displayed in the UI when user clicks a button.
    Previously I was using a pretty dumb hand-written version of WebClient based requests which were the fastest, but those have stopped working since the server has switched to https (nope, this can't be fixed using ServicePointManager.ServerCertificateValidationCallback).
    Where could I be digging to to try and reduce the time overhead?
     
  32. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @AlexRyder

    The S at the end of HTTPS adds a lot of overhead. The default SSL/TLS handler of the plugin is also a fully c# code, and it's not optimized for speed. With HTTPS a lot of time spent in decryption.
     
  33. AlexRyder

    AlexRyder

    Joined:
    Jul 3, 2017
    Posts:
    10
    @BestHTTP
    So, the 500 ms overhead just for SSL/TLS is supposed to be expected? Still, seems a bit too much...
     
  34. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @AlexRyder

    Mostly yes, other overhead comes because all code is written in c#, all data have to travel through additional layers. Creating a new thread, waiting for execution and waiting for a new unity update event also adds a little time. But the largest overhead is comes from encryption/decryption.
     
  35. AlexRyder

    AlexRyder

    Joined:
    Jul 3, 2017
    Posts:
    10
    @BestHTTP
    Hmm, OK then. Will have to consider between using WWW and BestHTTP now, thought the whole purpose was to move out background network operations into a separate thread and I'm pretty sure Unity's WWW is not safe to be called from another thread.
    And speaking of threads, is there currently a way to call HTTPRequest in a thread blocking fashion? My previous snippet seems to be a really ugly workaround which still produces all the thread jumping related overhead.
     
  36. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @AlexRyder

    You can do something like this to disable the plugin's callback mechanism:
    Code (CSharp):
    1. IEnumerator DisableAutoDispatch()
    2. {
    3.     HTTPUpdateDelegator.CheckInstance();
    4.     yield return null;
    5.     HTTPUpdateDelegator.Instance.gameObject.SetActive(false);
    6.  
    7.     // Start custom thread to call
    8.     //HTTPManager.OnUpdate();
    9. }
    Then you can call HTTPManager.OnUpdate() from your own thread.
     
  37. BowenLee

    BowenLee

    Joined:
    Jun 21, 2017
    Posts:
    3
    I can't use HTTPRequest in ipv6only with ios.

    unity 2017.2.0.p3
    .net 4.6
    in ios 10.0 and ipv6 only (using mac share internet)

    HTTPRequest request = new HTTPRequest(new Uri("https://google.com"));
    request.Send();

    in xcode console:
    NSURLConnection finished with error - code -1001
    HTTP load failed (error code: -999 [1:89])
     
    Last edited: Dec 2, 2018
  38. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @BowenLee

    NSURLConnection is an iOS specific class, something that the plugin does not use.
    You specified no callback to the request, you can't know whether it's finished successfully or not. You can write something like this:
    Code (CSharp):
    1. Uri uri = new Uri("https://google.com");
    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();
    Anyway, if you want to use the new runtime, I would suggest to use a newer version of Unity too. 2017.2.0.p3 is more than one year old (released: 27 November 2017), there were a lot of fixes in the runtime since.
     
  39. BowenLee

    BowenLee

    Joined:
    Jun 21, 2017
    Posts:
    3
    I try your code,but something wrong is happened
    it's only happened in ipv6only network(using mac for share)
    In ipv4 wifi,everything is fine

    it's the XCODE console,and the UnitywebRequest is work! But besthttp is not
    and safari can view the google website


    Request Finished with Error! Could not resolve host 'google.com'

    at System.Net.Dns.Error_11001 (System.String hostName) [0x00000] in <00000000000000000000000000000000>:0

    at System.Net.Dns.hostent_to_IPHostEntry (System.String originalHostName, System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) [0x00000] in <00000000000000000000000000000000>:0

    at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in <00000000000000000000000000000000>:0

    at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000] in <00000000000000000000000000000000>:0

    at System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress) [0x00000] in <00000000000000000000000000000000>:0

    at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0

    BestHTTP.HTTPRequest:CallCallback()

    BestHTTP.ConnectionBase:HandleCallback()

    BestHTTP.HTTPManager:OnUpdate()
     
  40. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @BowenLee

    As you can see the plugin used the framework provided Dns.GetHostAddresses, if it fails, the plugin can't do anything.
    The more than one year old 2017.2.0.p3 labeled the new runtime as Experimental (even there was a bug that I know of in the networking stack after they labeled the new runtime as Stable).
    I suggest to use a recent version of Unity for the new runtime.
     
  41. BowenLee

    BowenLee

    Joined:
    Jun 21, 2017
    Posts:
    3
    Cromfeli likes this.
  42. grogshotgames

    grogshotgames

    Joined:
    Aug 6, 2015
    Posts:
    77
    Hello!

    What's the best way to handle missing packets when using a socket connection?
    We've created a protocol in which the client sends an ACK whenever we Emit() and the server modifies a SEQ every time this ACK has been successully received in order. We store these Emit's data in a dictionary.

    If the server receives an ACK which value doesn't match the one it's specting on the server, we ask the client to send again every Emit since this error occured (hence storing it in a dictionary), until that package is re-send and processed correctly, the server won't process any other petition made by the client. After the server has processes the petition correctly, it notifies the client, which clears this specific data from the dictionary.

    Basically it's like:
    - Client sends Emit() with ACK 1.
    + Server receives packet. Processes ACK 1. Set SEQ to 2 (to compare the next petition sent, whenever it's done). Passes it to the client on the response.
    - Client receives the callback.
    - Client Emits() two new petitions with ACK 2 and 3.
    + Server receives ACK 3, but not ACK 2. We don't process it as we're expecting ACK 2 first.
    + Server asks for eveything up from ACK 2.
    - Client Emits() petitions with ACK 2 and ACK 3 again.
    + Server receives it correctly...

    Not sure if I made my self clear.
    Are we doing this correctly? Is there any easier way to achieve this? If so, can you point me in the right direction, please?
     
  43. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @grogshotgames

    It sounds good, but one thing isn't clear to me and it's the why. Are you had issues in the past or you want to prepare for the worst?
    Because loosing messages should happen only when the TCP channel became broken and both peers (client and server) needs time to recognize this. Until these messages kept small so they will not allocate too much memory until the plugin reconnects, it's a good way to make sure that messages reach the server.
     
  44. grogshotgames

    grogshotgames

    Joined:
    Aug 6, 2015
    Posts:
    77
    To be honest, I joined this project when BestHTTP was already implemented and the ACK/SEQ protocol was already set in. My guess is that yeah, they had issues in the past and hence implemented this.

    Let's say for example that a client sends 5 packages when the connection state is poor at that moment. If packet 3 gets lost, does the TCP socket automatically resolve this asking for it again and forcing this packet to be processed before the rest that arrived to the server before this one did?

    Isn't all this we're doing necessary?

    I'm not really server-side savvy, to be honest, so I basically doubt every step I take into this issues.
     
  45. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @grogshotgames

    TCP already implements acks to make sure all packages are received and in order. When it can't deliver the messages, it will report a disconnected channel.
    So, viewing it from this viewpoint it's just pointless.
    On the other hand, because of socket.io's reconnect mechanism, this can be a very valid one as it will open a new tcp channel that just doesn't know about the unsent messages...

    So, for important messages it's good as the other peer will receive the messages even when reconnects, however i would add it only to important messages.
     
  46. ncortesp

    ncortesp

    Joined:
    Oct 28, 2016
    Posts:
    42
    Hi, I have one question about the plugin.

    We are currently working with your plugin in order to manage all our in-game connections (REST, OneSignal...). Everything works OK (Android + iOS), but now we are moving to WebGL in order to incorporate our games to Facebook.

    What I see is that there are some missing headers that I can't see with my Rest API requests. I can see them in the inspector window of my navigator but... can't reach them by code.

    I've tried to print all available headers and I just see one of them; "content-type". I would like to reach the date for example.

    Am I doing something wrong? This feature is working perfectly with Android and iOS.

    Code (CSharp):
    1. HTTPRequest request = new HTTPRequest(new Uri("https://www.google.com"));
    2. request.SetHeader("Access-Control-Allow-Credentials", "true");
    3. request.SetHeader("Access-Control-Allow-Headers", "Accept, X-Access-Token, X-Application-Name, X-Request-Sent-Time");
    4. request.SetHeader("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE");
    5. request.SetHeader("Access-Control-Allow-Origin", "*");
    6. request.Send();
    7. yield return StartCoroutine(request);
    Code (CSharp):
    1. foreach (string key in _serverResponse.Headers.Keys)
    2. {
    3.        SGO.Log("KEY: " + key);
    4.        foreach (string val in _serverResponse.Headers[key])
    5.        {
    6.               SGO.Log("VAL: " + val);
    7.        }
    8. }
    9.  
    10. // Here I see just the "[B]Content-Type[/B]" headers (WebGL).
    11. // I can reach "[B]Date[/B]", "[B]BuildVersion[/B]"... headers (Android + iOS).
    12.  
    13. _serverResponse.GetHeaderValues("Date")[0])
     
  47. grogshotgames

    grogshotgames

    Joined:
    Aug 6, 2015
    Posts:
    77
    Our game is actually sort of a turn based multiplayer. Its a penalty/kicks game where you either shot or block, and change positions afterwards, doing one or another each turn. Both players are connected at the same moment, but it works as in:
    - Player A inputs the shot. The shot animation plays.
    - Player B receives the shot.
    - Player B sends the block. The shot and block animations play.
    - Player A receive the block. The block animation plays.


    We can't simply end the connection if there's a problem.
    We make it reconnect and send everything the server didn't read if that was the case.

    EDIT:
    By the way, a lot of warnings (nearly 500) are generated regarding definition dupes, like this:
    Code (CSharp):
    1. Assets/Best HTTP (Pro)/BestHTTP/SecureProtocol/asn1/anssi/ANSSINamedCurves.cs(30,15): warning CS0436: The type `Org.BouncyCastle.Asn1.X9.X9ECParametersHolder' conflicts with the imported type of same name'. Ignoring the imported type definition
    2.  
    3. Assets/Best HTTP (Pro)/BestHTTP/SecureProtocol/asn1/Asn1Encodable.cs(7,5): warning CS0436: The type `Org.BouncyCastle.Asn1.IAsn1Convertible' conflicts with the imported type of same name'. Ignoring the imported type definition
    4.  
    5. Assets/Best HTTP (Pro)/BestHTTP/SecureProtocol/asn1/Asn1InputStream.cs(17,11): warning CS0436: The type `Org.BouncyCastle.Utilities.IO.FilterStream' conflicts with the imported type of same name'. Ignoring the imported type definition
    6.  
    All of these seem to reference the BestHTTP asset and I haven't been able to find a second reference anywhere else in my project.
    I know these are harmless, but is there any way to fix these warnings?

    This is happening to me using the latest asset version on Unity 2018.2.10
     
    Last edited: Dec 5, 2018
  48. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    ncortesp likes this.
  49. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @grogshotgames

    It seems to be a good option to solve the reconnection problem.

    The plugin shouldn't generate any warnings. There might be another plugin with a dll that contains these classes too.
     
  50. sofianehamza

    sofianehamza

    Joined:
    Feb 13, 2017
    Posts:
    19
    hello, i've just purchased the asset, i was hoping i could use it with playmaker
    right now i need it in downloading large files and resume downloading
    thanks