Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    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,383
    @le_duke

    When you say the plugin is saving the cache library after each request, you mean you write a file with metadata about all entries each time ? (like path, date of caching etc.)

    Yes.

    Yes but what happen if app crash ? will your code handle it anyway ?

    The plugin will delete those entries that are saved but not in the library (in the metadata).

    I'm sorry to say that I bought this plugin to gain time but at the moment this is not very succesful...
    I'm not going to hide from you that I expected better for a plugin at this price.


    I'm thankful for your opinion and feedback. You can reach me out in email with purchase # so I can request a refund in the asset store.
     
  2. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    Hey guys! Starting tomorrow (09.) i will be on vacation until 18. of this month.
    My availability will be very limited through this time.
     
    Cromfeli likes this.
  3. nelsongames

    nelsongames

    Joined:
    Jun 6, 2018
    Posts:
    8
    Hello just purchased

    OnMessageReceived in WebsocketSample.cs seems to be for only text messages, which takes up more data than sending smaller bytes of data. For example if I want to send a bool, I can just send (byte) from the server and 0 would be no, and yes would be 1.

    What I'm trying to ask is. How can I send custom byte[] data that is not a text/string for websockets. How well is this optimized, I want to start a game and support 1,000 players.

    Are there any docs?


    Edit: Nevermind found the docs and saw the "OnBinary" event. This is awesome man, I've been looking for a stable websocket library for C# mostly open source, only found 2 "okay" ones, but they all lacked decent docs. I'm very impressed so far definitely worth the price.

    One question though, will this work on console platforms like Xbox One and PS4? As I want to publish my games on those.
     
    Last edited: Jun 9, 2018
  4. UglyDuckling

    UglyDuckling

    Joined:
    Mar 18, 2015
    Posts:
    5
    Hi, I had some problems with the latest version 1.10.7 and SignalR Core.

    To get it to work with hubs that require authentication I had to modify some code in HubConnection.cs

    Code (CSharp):
    1.  
    2. var request = new HTTPRequest(builder.Uri, HTTPMethods.Post, OnNegotiationRequestFinished);
    3.  
    4. // This is required, or the negotiation request errors with http status 401.
    5. AuthenticationProvider.PrepareRequest(request);
    6.  
    7. request.Send();
    8.  
     
  5. chuyuanzhang

    chuyuanzhang

    Joined:
    May 31, 2018
    Posts:
    3
    upload_2018-6-11_10-13-10.png Just like this output again
     
  6. bilde

    bilde

    Joined:
    Nov 13, 2015
    Posts:
    2
    I have the same issue as db82?!?! Have this not been fixed?
     
  7. bilde

    bilde

    Joined:
    Nov 13, 2015
    Posts:
    2
    Is it possible to get the code for the example above? You it seems to solve the issue I am facing! Cannot get Socket.io to work with BestHTTP and Hololens Emulator. Keep getting no connection when trying with the basic example uri:
    var manager = new SocketManager(new Uri("http://chat.socket.io/socket.io/"));

    Please help!
     
  8. chuyuanzhang

    chuyuanzhang

    Joined:
    May 31, 2018
    Posts:
    3
    NO
     
  9. nelsonlarocca

    nelsonlarocca

    Joined:
    Aug 11, 2014
    Posts:
    15
    Hi !
    I'm trying to post something to a server holding a private certificate. It works fine from the Unity editor itself, no even needed to use a CustomVerifier, but when running from an Android device it doesn't work.
    Any help about that ?
    Thanks
     
  10. Katori

    Katori

    Joined:
    Nov 30, 2009
    Posts:
    60
    I just wanted to say thanks for the great support of SignalR Core and the WebGL platform. Your support of these technologies together has allowed me to quickly iterate on a multiplayer game with MUCH better results than passing SignalR events through JavaScript on the webpage, which is what I was doing before. Thanks a bunch and I can't wait to see the refinements that come to the SignalR Core support!
     
    BestHTTP likes this.
  11. grogshotgames

    grogshotgames

    Joined:
    Aug 6, 2015
    Posts:
    76
    Hello!

    I have a question. HTTPManager.MaxConnectionPerServer handles the simultaneous connection to a single host.
    On iOS devices, according to this and this, there are a maximum of 5 simultaneous connections allowed too, hence making MaxConnectionPerServer irrelevant for ios if the value is higher than 5, right?

    Is there a way to modify the native iOS HTTPMaximumConnectionsPerHost directly from Unity or Xcode. My Xcode knowledge is VERY limited, just to say.

    Thanks!
     
    Last edited: Jun 19, 2018
  12. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @nelsongames

    I don't have access to devkits, so I don't know whether it works on them or not. I appreciate every feedback however!
     
  13. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
  14. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @chuyuanzhang

    Got no other reports for an error like this. Do you have any reproduce steps?
     
  15. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @bilde

    What version of the plugin are you using? All fixes that you quoted are in the plugin long time ago.
    Also, http://chat.socket.io/ is closed, no wonder you can't connect to it.
     
  16. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @nelsonlarocca

    The plugin doesn't do any verification by default, and that's the default behavior on android too. What error are you receiving?
     
  17. BestHTTP

    BestHTTP

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

    The plugin doesn't use platform specific classes, it opens TCP connections to the server on its own, so those limitations isn't applied.
     
  18. grogshotgames

    grogshotgames

    Joined:
    Aug 6, 2015
    Posts:
    76
    I see, great. Thanks for letting me know! :)
     
    Cromfeli likes this.
  19. melefans

    melefans

    Joined:
    Aug 1, 2016
    Posts:
    36
    Hello
    Does besthttp open compression by default?
    Webgl platform compression can not be used?
     
  20. BestHTTP

    BestHTTP

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

    By default the plugin will ask the server to if possible use gzip compression. Under WebGL the plugin has much less control over the request, but browsers are asking for compressed data too.
     
  21. melefans

    melefans

    Joined:
    Aug 1, 2016
    Posts:
    36
    thanks for your reply..
    Sometimes I find some error in the unity dashboard. Every day there are such error.

    1. SocketException: The requested address is not valid in this context

    System.Net.Sockets.Socket.Send (System.Byte[] buf, Int32 offset, Int32 size, SocketFlags flags)
    System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size)
    Org.BouncyCastle.Crypto.Tls.RecordStream.WriteRecord (Byte type, System.Byte[] plaintext, Int32 plaintextOffset, Int32 plaintextLength)
    Org.BouncyCastle.Crypto.Tls.TlsProtocol.SafeWriteRecord (Byte type, System.Byte[] buf, Int32 offset, Int32 len)
    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)
    BestHTTP.WebSocket.WebSocketResponse.Send (IWebSocketFrameWriter frame)

    2. IOException: Internal TLS error, this could be an attack
    Org.BouncyCastle.Crypto.Tls.TlsProtocol.WriteHandshakeMessage (System.Byte[] buf, Int32 off, Int32 len)
    BestHTTP.WebSocket.WebSocketResponse.Send (IWebSocketFrameWriter frame)

    When I get this error, I don't seem to be able to catch the error by OnError callback

    Can you provide some solutions or some suggestions ?
    thanks a lot...
     
    Last edited: Jun 21, 2018
  22. BestHTTP

    BestHTTP

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

    Most probably the exceptions are thrown because of the TCP connection is down.
    What version of the plugin are you using? I made some improvement around websocket error handling.
     
  23. melefans

    melefans

    Joined:
    Aug 1, 2016
    Posts:
    36
    i can't find the version , I see git update time is 2017.5。
    no websocket compression feature.
     
  24. BestHTTP

    BestHTTP

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

    There should be a ReleaseNotes.txt in the \Best HTTP (Pro)\ folder. But, if it's from 2017 May, then its version is max 1.10.0.

    If you can update the plugin, these errors will remain, but you should receive an OnError callback at least.
     
  25. melefans

    melefans

    Joined:
    Aug 1, 2016
    Posts:
    36
    Ok, thank you very much for your help
    I will upgrade to the latest version and then continue to monitor these issues.
     
  26. nelsongames

    nelsongames

    Joined:
    Jun 6, 2018
    Posts:
    8
    How can you reset the connection to the host and reconnect properly? When I do webSocket.close(), webSocket = null, and then re instantiate it, I get an error that the webSocket is null.
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @nelsongames

    Can you share your relevant code? Are you sure you are not trying to use the (null) webSocket?
     
  28. donedgardo

    donedgardo

    Joined:
    Jun 22, 2018
    Posts:
    1
    Hi really love your sdk, @BestHTTP
    Is there a way we could add headers to the scoket.io manager?
    Something like this?:

    Code (JavaScript):
    1. var socket = io("http://localhost", {
    2.   extraHeaders: {
    3.     Authorization: "Bearer authorization_token_here"
    4.   }
    5. });
     
  29. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @donedgardo

    Unfortunately you can't set custom headers, only query parameters.
     
  30. echuang98

    echuang98

    Joined:
    Oct 21, 2015
    Posts:
    17
    Hello :)
    I know I can create a websocket client with BestHTTP and connect to an existing websocket server.
    I would like to know if I can create a websocket server with BestHTTP?
     
  31. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
  32. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    18
    Hi
    Just purchased BestHTTP, I have a first naïve question :)
    In order to improve my experience in managing real time applications in Unity, I'm trying to implement my own (self-hosted at moment) SignalR server to run the "ConnectionAPISample". I'm following, without succeeding, the server creation part of this guide: http://www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host.
    I was wondering if is it possible to get a sample code to start not from scratch.
     
    Last edited: Jun 29, 2018
  33. echuang98

    echuang98

    Joined:
    Oct 21, 2015
    Posts:
    17
    Got it. Thanks!
     
  34. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @berry4u

    All client-side samples are included in the package, and the server side uses the original samples of SignalR.

    But, if you are just starting to implement your real-time app, i wouldn't recommend to use the old SignalR. My recommendation would be to use SignalR Core instead. The plugin supports this too (BestHTTP.SignalRCore namespace), although i had no time to write the documentation and a usage sample for it. Although its API quite straightforward (or at least I hope so).
     
  35. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    18
    Ok @BestHTTP, thank you so much for the hints.
     
  36. spiderpoison

    spiderpoison

    Joined:
    Jul 2, 2018
    Posts:
    8
    I have a question, If i handle protocol by " OnBinary", will the receiving be blocked?
    Handle protocol:
    upload_2018-7-2_10-16-30.png
    Receiving:
    upload_2018-7-2_10-17-21.png
     
  37. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @spiderpoison

    Yes, while OnBinary is busy, no frame processing is executed. Sent a new package in private that contains improvements for this.
     
  38. TriPawCat

    TriPawCat

    Joined:
    Nov 23, 2015
    Posts:
    7
    We use socket connection in game, and use BestHttp to send some other datas. It works fine on Android, but on iOS, if the data server is not available, it will block the game socket, until the timeout exception thrown by BestHttp.
     
  39. guoweisong3

    guoweisong3

    Joined:
    Jul 3, 2018
    Posts:
    2
    I have looked your new package ,I find that your code "frameCache.AddRange(CompletedFrames);"in the OnUpdate mothod ,on the end "frameCache.Clear();" so when the Memory is too huge ,this frame will GC ,so that while OnBinary is busy,no frame processing is executed also ?
     
  40. BestHTTP

    BestHTTP

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

    Can describe what and how are you doing in more detail?
    You have one socket (TCP or UDP) connected to a server. This is a non-BestHTTP one.
    How you are sending 'other datas' with BestHTTP? With HTTP requests or using something higher level protocol (websocket, socket.io, etc.)? Are the non-besthttp and the besthttp ones connecting to the very same server?

    What operation is blocked on the first (non-besthttp) socket while besthttp tries to connect? It can't connect, or can't read/write data?
     
  41. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @guoweisong3

    frameCache is just an other list to hold the completed frames that are ready to dispatch. It contains only the references to the frames, there's only a minimal allocation when the list grows. But, while the HandleEvents iterates through this frameCache the receive thread can add newly downloaded frames to the completedFrames list.

    frameCache.Clear() will not 'release' any memory. Its internal buffer will be still there, only zeroed out to do not hold any reference to the dispatched completed frames. This is the same as previously the completedFrames.Clear().

    I think GC will be triggered on allocations when there's not enough memory, so it can happen anywhere. If it happens while the plugin does it's event dispatching, then, well, all remaining events will be delayed until GC finishes. GC will also pause all threads AFAIK, so downloading new frames will be delayed too.
     
  42. TriPawCat

    TriPawCat

    Joined:
    Nov 23, 2015
    Posts:
    7
    Hi, thank you for your reply. We use TCP socket for non-BestHTTP one, and they connect to different servers. We just use the SendRequest(HTTPRequest request) API to send 'other datas'.

    The non-BestHTTP one can't write data when blocked;
     
  43. BestHTTP

    BestHTTP

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

    That's interesting, are you using the new 4.6 .NET runtime?
     
  44. BenjaminUbisoft

    BenjaminUbisoft

    Joined:
    Apr 20, 2018
    Posts:
    2
    Hello,

    I would like to add a HMAC on my post requests. Problem : after my post has been feed with parameters, there is no way to access the data to calculate its HMAC.
    Is there a way to perform this ?

    Thank you
     
  45. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @BenjaminUbisoft

    I guess you are using the AddField/AddBinaryData functions add data. In what format you would need to access the data you previously set? A list of those key-value pairs, or the bytes that the plugin will send to the server?
     
  46. TriPawCat

    TriPawCat

    Joined:
    Nov 23, 2015
    Posts:
    7
    No, we use .NET 2.0 subset, bind with Unity5.5.5. Maybe it's something wrong with our code, but it works fine on Android, that confused. I set stopwatch round the game socket write method, found it cost a lot of time.
    Oh, it only blocks on iOS devices, won't block in the Unity Editor.
     
    Last edited: Jul 4, 2018
  47. BenjaminUbisoft

    BenjaminUbisoft

    Joined:
    Apr 20, 2018
    Posts:
    2
    I am indeed using these functions, and any of your two solutions would suit.
     
  48. BestHTTP

    BestHTTP

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

    That's getting more and more interesting, the plugin can run requests in parallel, i think they would block each other as all of them are using TCP. Can you send a repro project so i can see it myself? (I tried to make a simple one, but hadn't able to reproduce it)
     
  49. karlsevenvii

    karlsevenvii

    Joined:
    May 3, 2016
    Posts:
    4
    Hi, First this plugin is very great! been using this with all my previous projects. but since i think 1.10.x ive been having problems with the plugin, i honestly dont know if im sure, but i had this function with realtime player moving, it was working before when i walk a character in my editor and the other one using my phone, but using the latest plugin on some occassion when i stop walking using my phone and i control the one in the editor it doesnt update the one in the phone i have to move the player first then the player in my editor just jumps to its location, and it happens vice versa. i would understand that it will have that behavior in editor since if the editor is not in focus it doesnt update. but in the phone i think theres a problem. sorry for my english and i hope you get what i mean.

    Thanks! help is greatly appreciated.
     
  50. spiderpoison

    spiderpoison

    Joined:
    Jul 2, 2018
    Posts:
    8
    we connect to server using besthttp websocket , sometimes, server will err "use of closed network connection" when receive msg.
    why?