Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Best HTTP Released

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

  1. TRsiew

    TRsiew

    Joined:
    Jul 5, 2013
    Posts:
    13
    thanks.. i will try it .

    when the BestHTTP can support webgl ?
     
  2. MartinCA

    MartinCA

    Joined:
    Jan 1, 2012
    Posts:
    15
    Another BestHTTP question :)

    In our current project, we use BestHTTP both in game and in some editor extensions (some data editors for our game, they use the same API as the game module)

    To get BestHTTP running in the editor, I simply call BestHTTP.HTTPManager.Setup() when the editor is opened, and manually pump the Update message on the editor's GUI method. So far this works great.

    The problem I encountered, is that after running an editor, when entering play mode the game will sometime freeze.
    I am guessing the editor assembly doesn't get unloaded when entering play mode which causes some conflicts - guessing it has something to do with the thread locking, or maybe some access locking to the cache - I honestly don't know how the editor and game assemblies interop inside the editor.

    Question is - is there any supported way to forcefully shut down BestHTTP? Haven't found any method to do that short of calling connection.Abort()/Dispose() - but since everything on that level is defined as internal, I cannot access the connection list without heavy modifications to the sources, which I would prefer to avoid :)

    Thanks!
     
  3. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @MartinCA Interesting problem, and i will check it out. The HTTPManager has an OnQuit method to clean up things, but it's also set to internal. And also, it may not help in this case anyway...
    (OnQuit will already receive some improvement in the next update.)

    So, for now i can't give a straight advice, but i will do my best to bring up one.
     
  4. MartinCA

    MartinCA

    Joined:
    Jan 1, 2012
    Posts:
    15
    Thanks for the update!

    Right now it's not a big issue (aside from having to deal with whiny content people :p), so I'm going to keep ignoring gracefully as I have done so far.

    It would be awesome if you could keep me posted when an updated is available which could resolve this issue, and at any rate if this escalates on our side I'll try to hack something together (either chop into BestHTTP or maybe try to force unload the editor assembly when entering playmode) - so no rush there.

    Thanks for the awesome support btw!
     
  5. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @MartinCA Tried to reproduce without any luck. :(
    But made some steps to make it easier to use in editor mode... :)
     
  6. isykaleo

    isykaleo

    Joined:
    Jun 27, 2015
    Posts:
    4
    Hi there,

    Thank you for making such a great plugin!

    We have recently used Best HTTP in our app to download asset bundle resources from our server.
    It has been working perfectly for over 2 weeks (it was great!).

    However, starting today; we are getting mass report of failed downloads.
    We tested the code, and this error is found:
    R1Z_]G9D$17AANV59UTH)AN.jpg

    This error suddenly started to appear today; no modifcations were made on the code during this period.
    Our team is desperate to retore our APP, any help or idea on how to solve this would be very much appreciated.

    Many thanks again!
    Best regard,

    Isaac
     
  7. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @isykaleo While i check how is it possible to reproduce it, i think setting a lower value to the HTTPManager.MaxConnectionIdleTime should lower the chance to get this error. The default value is 30 secs, you may try to set it to 15, 10 secs:
    Code (CSharp):
    1. HTTPManager.MaxConnectionIdleTime = TimeSpan.FromSeconds(10);
    If it isn't setting the HTTPManager.KeepAliveDefaultValue to false must resolve it:
    Code (CSharp):
    1. HTTPManager.KeepAliveDefaultValue = false;
     
  8. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    Uploadad v1.9.0 to the Asset Store for preview. Hopefully it will be released this week.

    This is a major release where user interaction required to upgrade!
    To upgrade you will have to delete the /Assets/Best HTTP (Pro|Basic)/ folder, and the BestHTTP.dll and TcpClientImplementation.dll from the /Assets/Plugins/, /Assets/Plugins/Metro/ and /Assets/Plugins/WP8/ folders.

    TcpClientImplementation's source is merged into the main source, removed a lot of source code from it.

    Complete release notes for this release:
    Windows Phone 8 silverlight based build support removed!
    General
    • [New Feature] Various features can be disabled now with the following defines:
    • BESTHTTP_DISABLE_COOKIES
    • BESTHTTP_DISABLE_CACHING
    • BESTHTTP_DISABLE_SERVERSENT_EVENTS
    • BESTHTTP_DISABLE_WEBSOCKET
    • BESTHTTP_DISABLE_SIGNALR
    • BESTHTTP_DISABLE_SOCKETIO
    • BESTHTTP_DISABLE_ALTERNATE_SSL
    • BESTHTTP_DISABLE_UNITY_FORM
    • Check the manual on how you can set these in Unity: http://docs.unity3d.com/Manual/PlatformDependentCompilation.html
    • [Improvement] Removed DLL depenencies
    • [Improvement] Improved HTTPConnection teardown on quitting
    • [Improvement] Improved compatibility when used in an editor window
    • [Bugfix] Cookies are stored from redirections
    Socket.IO
    • [Bugfix] WebSocketTransport not switched to secure protocol when the Uri of the socket.io endpoint is HTTPS
    • [BugFix] Disconnect event not fired when the server initiated the disconnect (Thx go to Takayasu Oyama)
    SignalR
    • [Bugfix] WebSocketTransport not reconnected properly (Thx go to Jaakko Jumisko)
     
    Last edited: Aug 3, 2015
  9. earthcrosser

    earthcrosser

    Joined:
    Oct 13, 2010
    Posts:
    121
    Hi, I'm interested in getting Best Http
    I have some javaScript code that essentially creates an event source like so
    Code (JavaScript):
    1. var source = new EventSource("http://whatever:port/myendpoint");
    2.             source.addEventListener("message", function(event) {
    3.                   //stuff
    4.             });
    5.  
    would BEST HTTP allow me to do basically the same thing with C# code?
     
  10. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @earthcrosser Some names are changed(like addEventListener(...) => On(...)), but you can basically do the same with my implementation:
    Code (CSharp):
    1. var source = new EventSource(new Uri("http://whatever:port/myendpoint"));
    2. source.On("message", (eventSource, msg) =>
    3.     {
    4.         Debug.Log(msg.Data);
    5.     });
     
  11. MadByteLabs

    MadByteLabs

    Joined:
    May 29, 2011
    Posts:
    18
    Hi, i use BestHTTP with pomelo http://pomelo.netease.com/. This is node.js based framework. I call
    Code (CSharp):
    1.  
    2. SocketOptionsoptions = newSocketOptions ();
    3. options.AutoConnect = false;
    4. options.QueryParamsOnlyForHandshake = false;
    5. Manager = new SocketManager (new Uri ("http://localhost:3010/socket.io/"), options);        
    6. Manager.Socket.On (SocketIOEventTypes.Connect, (socket, receivedPacket, args) => Debug.LogError ("---Connect---"));
    7. Manager.Socket.On (SocketIOEventTypes.Error, (socket, packet, args) => Debug.LogError (string.Format ("Error: {0}", args [0].ToString ())));        
    8. Manager.Open ();
    and get error
    Code (CSharp):
    1. Err [HandshakeData]: Handshake request failed with error: Invalid handshake text: Welcome to socket.io.
    2. Error: Code: Internal Message: "Invalid handshake text: Welcome to socket.io."
    3.  
    If use another soket.io client library connect is successful. Thanks.
     
    Last edited: Aug 4, 2015
  12. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @Lestar: As i see Pomelo uses an old version of Socket.IO that my plugin doesn't support. Pomelo depend on version 0.9.16, while BestHTTP requires at least 1.2 (1.0, 1.1 may work too, but not tested them).
    1.0 released more that a year ago, and the current version is 1.3.6.
     
  13. MadByteLabs

    MadByteLabs

    Joined:
    May 29, 2011
    Posts:
    18
  14. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    239
    When using a non-SSL server/client connection the client connects to the server just fine.

    Converting the server to SSL and connecting shows the client connecting. However, the 'connected event' never occurs in Unity3D. Then every like ~10 seconds it just reconnects. Eventually the transport will timeout in Unity3D showing errors about it timing out.

    My firewall is left untouched. There is no other errors shown on the server or client that I can see. I was able to use the same configuration to connect with a local webpage but not the remote BestHTTP setup.

    Is there perhaps a secure variable or something that I don't know about in BestHTTP?



    Edit: Tested it on a different engine with even an older Socket.IO client version and the same code worked perfectly fine. The only way to manipulate a similar occurrence is the other engine is if I connect without a namespace entered. So in BestHTTP I'm going to try to specify a namespace and connecting to that.

    Edit2: Doesn't seem to have made a difference.

    Edit3: Manager.State inside the connecting variable shows "Initial" and then every time it is actually "Reconnecting" though I have no idea why it keeps reconnecting with no prior error or disconnection.
     
    Last edited: Aug 6, 2015
  15. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @Blueberry: Looks like that's because of the default (mono's) ssl handler. This is why i include a more advanced and fresh one.
    You can set the HTTPManager's UseAlternateSSLDefaultValue to true to turn it on on all requests(Socket.IO will use it too):
    Code (CSharp):
    1. HTTPManager.UseAlternateSSLDefaultValue = true;
     
    MrIconic likes this.
  16. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    239
    Doesn't seem to have worked but I appreciate the quick reply and I will use that if I do figure this out. Do you have any other ideas of what could be causing it? Barely- if anything is modified.

    I'm going to try placing it into a fresh project with absolutely nothing to see if it works later on when I can test that.
     
  17. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @Blueberry What a bad memory I have, but now at least it came to my mind. This should be fixed in the latest version. However this is not released yet by Unity, so sending a download link to you in private.
     
  18. Cheshire Cat

    Cheshire Cat

    Joined:
    Sep 18, 2012
    Posts:
    39
    Hey BestHTTP,

    I've bought your plugin and trying to create HTTP POST request of type

    So I tried it with the following code

    Code (CSharp):
    1. HTTPRequest request = new HTTPRequest(new Uri("https://dictation.nuancemobility.net/NMDPAsrCmdServlet/dictation"), HTTPMethods.Post,
    2. OnRequestFinished);
    3.  
    4.   request.AddField("appId", SOME_ID);
    5.   request.AddField("appKey", SOME_KEY);
    6.   request.AddField("id", SOME_ID);
    7.  
    8.   request.SetHeader("Content-Type", "audio/x-pcm;bit=16;rate=8000");
    9.   request.SetHeader("Accept-Language", en-US);
    10.   request.SetHeader("Accept", text/plain);
    11.  
    12.   request.Send();
    As a result I got 403 Error. So I've got two questions:

    1. What I am doing wrong?
    2. How is it possible to log the whole request which is sent?
    returns only the Uri, but not the parameters and headers.

    Please assist
     
  19. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    239
    Alright. Everything is fixed now. The 1.9.0 upgrade seemed to fix it. (I left the http change in there too just incase)

    Below was fixed by removing my script from the project that used BestHTTP , importing the package and then putting my script(s) back into the project.

    Thanks a bunch for the quick and awesome support. 5/5 :)


     
    Last edited: Aug 6, 2015
  20. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @Cheshire Cat

    1.) The server expects the ids and key in the uri of the request. The AddField will add data to the POST's body. Your request should look like this:

    2.) There is a DumpHeaders() function for the HTTPRequest class, but i would recommend to use an intermediate proxy instead (like Fiddler, Charles), it's more reliable.
     
  21. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @Blueberry Thank you for the feedback. I think something stuck in Unity, but will look into it.
     
    Last edited: Aug 7, 2015
  22. just_a_joke

    just_a_joke

    Joined:
    Apr 20, 2015
    Posts:
    13
    Hey BestHTTP,

    I just bought the plugin and now trying to use the signalR feature.

    By following the provided documentation, I success on connecting to the signalR server when running on the PC. But when I deploy the testing app to the phone device and running the same code, it return the following error :-

    One or more errors occured. at System.Threading.Tasks.Task.ThrowlfExceptional(Boolean includeTaskCanceledException) at
    System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at
    System.Threading.Tasks.Task.Wait(TimeSpan timeout) at
    BestHTTP.PlatformSupport.TcpClient.WinRT.TcpClient.Connect(String hostName, Int32 port) at
    BestHTTP.HTTPConnection.Connect() at
    BestHTTP.HTTPConnection.<ThreadFunc>d__1.MoveNext()

    The project is targeted Windows Phone 8.1 platform
     
  23. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @just_a_joke How can i reproduce it? I tried it with little luck.
    When an exception throws there, however it should reconnect if the SignalR protocol estabilished, or it should fall back to the next transport. While it can be a normal mechanism, it will log these errors/exceptions and can be misleading, as might think that it's failed.
     
  24. just_a_joke

    just_a_joke

    Joined:
    Apr 20, 2015
    Posts:
    13
    @BestHTTP The following code is how I start the SignalR connection :-

    private void signalrInit()
    {
    Connection signalRConnection = new Connection(new Uri(signalrUrl), "Server");

    signalRConnection.Open();

    signalRConnection.OnConnected += signalRConnection_OnConnected;
    signalRConnection.OnError += signalRConnection_OnError;
    signalRConnection.OnReconnecting += signalRConnection_OnReconnecting;
    signalRConnection.OnReconnected += signalRConnection_OnReconnected;
    signalRConnection.OnStateChanged += signalRConnection_OnStateChanged;
    signalRConnection.OnNonHubMessage += signalRConnection_OnNonHubMessage;
    }


    You did mentioned that it should reconnect when the error or exception throw but what I tested it never trigger the "OnReconnecting" or "OnReconnected" method.

    Did you tested on the Windows Phone device? Because I tried running with Unity on PC the code above working just fine but when deploy to device the error occur
     
    Last edited: Aug 13, 2015
  25. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @just_a_joke Subscribing to event should be done before you calls the Open function, but this is not the cause of your issue.
    Are you receiving this error when you connect? It would explain why the reconnect events doesn't fired.

    It would be great to have a detailed log output after you set the loggin level to All:
    Code (CSharp):
    1. BestHTTP.HTTPManager.Logger.Level = Logger.Loglevels.All;
    Also, is this issue reproducable with my samples too?
     
  26. just_a_joke

    just_a_joke

    Joined:
    Apr 20, 2015
    Posts:
    13
    @BestHTTP Yes, the error appear when starting the connection.

    Is there a way to capture or display the log output when deployed to device?

    I tested with the provided sample scene, it is working fine on PC which able to establish the connection but not working and display the same error on device.

    And I tried to change the SignalR Uri to point to my server SignalR but still same issue that working on PC but not device.
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @just_a_joke In Visual Studio you can see the debug output of Unity on the Ouput window(Debug/Windows/Ouput or CTRL+W+O shortcut).

    Also in the \Assets\Best HTTP (Pro)\BestHTTP\PlatformSupport\TcpClient\WinRT\TcpClient.cs you can change the
    Code (CSharp):
    1.                 var result = Socket.ConnectAsync(host, UseHTTPSProtocol ? "https" : port.ToString(), spl);
    2.                 Connected = result.AsTask().Wait(ConnectTimeout);
    3.  
    lines to

    Code (CSharp):
    1.             try
    2.             {
    3.                 var result = Socket.ConnectAsync(host, UseHTTPSProtocol ? "https" : port.ToString(), spl);
    4.                 Connected = result.AsTask().Wait(ConnectTimeout);
    5.             }
    6.             catch(AggregateException ex)
    7.             {
    8.                 if (ex.InnerException != null)
    9.                     throw ex.InnerException;
    10.             }
    11.  
    It may provide us a more detailed exception.
     
  28. just_a_joke

    just_a_joke

    Joined:
    Apr 20, 2015
    Posts:
    13
    @BestHTTP I added header "using BestHTTP" in the sample code, below is the error message :-

    [Error] No such host is know. (Exception from HRESULT: 0x80072AF9) at BestHTTP.PlatformSupport.TcpClient.WinRT.TcpClient.Connect(String hostName, Int32 port)
    at BestHTTP.HTTPConnection.Connect()
    at BestHTTP.HTTPConnection.<ThreadFunc>d__1.MoveNext()

    Running on phone device using the provided sample scene.
     
  29. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @just_a_joke I'm able to reproduce this only when I turn off my wifi and cellular data connection.
    Are the more basic, HTTP Samples (the "Texture Download" for example) are working on your device?
     
    Last edited: Aug 13, 2015
  30. just_a_joke

    just_a_joke

    Joined:
    Apr 20, 2015
    Posts:
    13
    @BestHTTP I managed to solved the problem that somehow when build and run using the unity into the phone device the network access is not activated even its had been checked on the capabilities. I need to build a C# project from unity then deploy to the phone using Visual Studio only able to get network access.

    But there is another problem that the client unable to received any message that broadcasted from the SignalR server. I call the server-side method with the following code :-

    signalRConnection["Server"].Call("connect", SharedResources.sessionId);

    When the admin check on the server log, the method did fire but on the client side I did not receive any message from the server although the event "OnNonHubMessage" had already registered.

    The server used Hub to broadcast, is this the problem that causes the client could not receive the message? If so any way that the client could receive the message from Hub broadcast?

    I tried to call the server-side method with different parameter like the following :-

    signalRConnection["Server"].Call("connect", OnGetValueDone, OnGetValueFailed, SharedResources.sessionId);

    But this is the error I get instead :-

    Ex [WebSocketResponse]: HandleEvents - Message: Object reference not set to an instance of an object StackTrace: at SignalRHelper.OnGetValueDone (BestHTTP.SignalR.Hubs.Hub hub, ClientMessage originalMessage, BestHTTP.SignalR.Messages.ResultMessage result) [0x00000] in C:\Users\teo.xc.GAINSECURE\Desktop\Magician\MathgicianWin2\MathgicianMobile\Assets\Scripts\Classes\Helper\SignalRHelper.cs:112
    at BestHTTP.SignalR.Hubs.Hub.BestHTTP.SignalR.Hubs.IHub.OnMessage (IServerMessage msg) [0x00090] in C:\Users\teo.xc.GAINSECURE\Desktop\Magician\MathgicianWin2\MathgicianMobile\Assets\Best HTTP (Pro)\BestHTTP\SignalR\Hubs\Hub.cs:255
    at BestHTTP.SignalR.Connection.BestHTTP.SignalR.IConnection.OnMessage (IServerMessage msg) [0x001a3] in C:\Users\teo.xc.GAINSECURE\Desktop\Magician\MathgicianWin2\MathgicianMobile\Assets\Best HTTP (Pro)\BestHTTP\SignalR\Connection.cs:670
    at BestHTTP.SignalR.Transports.WebSocketTransport.WSocket_OnMessage (BestHTTP.WebSocket.WebSocket webSocket, System.String message) [0x00025] in C:\Users\teo.xc.GAINSECURE\Desktop\Magician\MathgicianWin2\MathgicianMobile\Assets\Best HTTP (Pro)\BestHTTP\SignalR\Transports\WebSocketTransport.cs:127
    at BestHTTP.WebSocket.WebSocket.<OnInternalRequestUpgraded>m__28 (BestHTTP.WebSocket.WebSocketResponse ws, System.String msg) [0x0000b] in C:\Users\teo.xc.GAINSECURE\Desktop\Magician\MathgicianWin2\MathgicianMobile\Assets\Best HTTP (Pro)\BestHTTP\WebSocket\WebSocket.cs:268
    at BestHTTP.WebSocket.WebSocketResponse.BestHTTP.IProtocol.HandleEvents () [0x00079] in C:\Users\teo.xc.GAINSECURE\Desktop\Magician\MathgicianWin2\MathgicianMobile\Assets\Best HTTP (Pro)\BestHTTP\WebSocket\WebSocketResponse.cs:353
    UnityEngine.Debug:LogError(Object)
    BestHTTP.Logger.DefaultLogger:Exception(String, String, Exception) (at Assets/Best HTTP (Pro)/BestHTTP/Logger/DefaultLogger.cs:89)
    BestHTTP.WebSocket.WebSocketResponse:BestHTTP.IProtocol.HandleEvents() (at Assets/Best HTTP (Pro)/BestHTTP/WebSocket/WebSocketResponse.cs:368)
    BestHTTP.HTTPManager:OnUpdate() (at Assets/Best HTTP (Pro)/BestHTTP/HTTPManager.cs:551)
    BestHTTP.HTTPUpdateDelegator:Update() (at Assets/Best HTTP (Pro)/BestHTTP/HTTPUpdateDelegator.cs:67)



    Thanks
     
    Last edited: Aug 14, 2015
  31. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @just_a_joke If you called the "connect" function on the "Server", maybe the response is a hub-call too. Or is it returns with a value?
    For hub messages, you can set up a callback with the On function:
    Code (CSharp):
    1.         signalRConnection["Server"].On("ServerCalledFunction", (hub, methodCall) =>
    2.             {
    3.                 // TODO: handle event
    4.             });
    Also setting the logger level to All, the plugin will log out any unhandled methodcall to help debugging. (Unhandled result, failure and progress messages are not logged though)
     
  32. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @just_a_joke The exception is thrown in a non-plugin code(SignalRHelper.cs at line 112).
     
  33. just_a_joke

    just_a_joke

    Joined:
    Apr 20, 2015
    Posts:
    13
    @BestHTTP The "connect" function on the "Server" do not return value, instead it will broadcast an ID back to the client that called the function.

    The code at line 112 is pointing to this

    Code (CSharp):
    1. void OnGetValueDone(Hub hub, ClientMessage originalMessage, ResultMessage result)
    2.     {
    3.         Debug.Log("Connect function return : " + result.ReturnValue.ToString());
    4.     }
     
  34. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @just_a_joke When the return type of the function on the server-side is void, the ReturnValue property is null. You have to subscribe to the function that you are broadcasting to. Can you share your server-side code that relevant to this issue(your Connect function, or the code that you use to broadcast)?
     
  35. just_a_joke

    just_a_joke

    Joined:
    Apr 20, 2015
    Posts:
    13
    @BestHTTP The server admin is unavailable now, so I can't provide you the server code for now.

    Can you try to reproduce the scenario from your side?

    Below are the information for the signalR to reproduce the scenario :-
    If the client successful call the server function its should broadcast a GUID back to the client

    Thanks
     
  36. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @just_a_joke

    This code worked flawlessly:
    Code (CSharp):
    1. void SignalRTest()
    2. {
    3.     // Connect to the given url and hub
    4.     var connection = new BestHTTP.SignalR.Connection(new Uri("http://70e4f5a3-e22f-4104-9cda-57faea3491cc-mathgicianhexward.cloudapp.net/signalR/"), "Server");
    5.  
    6.     // When connected, call the "Connect" function on the server
    7.     connection.OnConnected += (con) => connection["Server"].Call("Connect", "447af81e-de71-40a5-ba30-f9ffb1deb7c6");
    8.  
    9.     // Bind a server-callable function to its implementation
    10.     connection["Server"].On("sendConnectionID", OnSendConnectionID);
    11.  
    12.     // Start connecting to the server
    13.     connection.Open();
    14. }
    15.  
    16. private void OnSendConnectionID(BestHTTP.SignalR.Hubs.Hub hub, BestHTTP.SignalR.Messages.MethodCallMessage methodCall)
    17. {
    18.     // The first, and only argument is an object
    19.     Dictionary<string, object> arg0 = methodCall.Arguments[0] as Dictionary<string, object>;
    20.  
    21.     // With one field: 'value'
    22.     Debug.Log("Argument: " + arg0["value"].ToString());
    23. }
    As i mentioned, when logging set to All in the log you can see a
    line. It's informs you that you have an unhandled function call on your client. The hub of the call is 'Server', and the name of the function is 'sendConnectionID' with one argument.
     
  37. twick

    twick

    Joined:
    Nov 16, 2011
    Posts:
    31
    I'm on Unity 5 Pro latest and get the following errors upon import. This is a new project with hardly anything in it.

    Assets/Best HTTP (Pro)/BestHTTP/PlatformSupport/TcpClient/TcpClient.cs(86,20): error CS1061: Type `Socket' does not contain a definition for `Bind' and no extension method `Bind' of type `Socket' could be found (are you missing a using directive or an assembly reference?)

    Assets/Best HTTP (Pro)/BestHTTP/PlatformSupport/TcpClient/TcpClient.cs(103,20): error CS1061: Type `Socket' does not contain a definition for `Bind' and no extension method `Bind' of type `Socket' could be found (are you missing a using directive or an assembly reference?)

    Assets/Best HTTP (Pro)/BestHTTP/PlatformSupport/TcpClient/TcpClient.cs(111,20): error CS1061: Type `Socket' does not contain a definition for `Bind' and no extension method `Bind' of type `Socket' could be found (are you missing a using directive or an assembly reference?)

    Also, socket.IO documentation seems to be outdated.
     
  38. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @twick I have the latest patch release, and can't reproduce it. My only bet was on that you set your project on an unsupported platform, but after checked on all available platform I wasn't able to reproduce it. Not seen or heard about this kind of issue yet, so can you share more information about your project setup? Also, importing the plugin in a fress project produces the same errors?

    Also, can you share more information about the outdated documentation? I didn't done or remembering about API or major implementation changes.
     
  39. twick

    twick

    Joined:
    Nov 16, 2011
    Posts:
    31
    Ugh... Ignore me. It appears I had made a script called Socket... obviously not thinking. It was making conflicts. /facepalm.
     
  40. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @twick Well, you can keep the Socket name, just put it in a namespace.
     
  41. fat_flying_pigs

    fat_flying_pigs

    Joined:
    Feb 3, 2014
    Posts:
    4
    I have a project that will be pulling config data off a url; however this url is an intranet url. Normal Unity www does not work without some non-standard witchcraft (for each device). I saw this in the asset store and was wondering if it can handle the necessary proxy related stuff to work on my project. I'm a noob at networking, so I'm not sure how much different a general proxy and an intranet url is...

    A simple second question, will this package function like the normal www class where it will stream data asynchronously? (ie: no lag if I want to pull the config data occasionally in the background)
     
  42. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @fat_flying_pigs
    Internal urls are the same as other urls. A dns server will respond with its ip address. So it should work just fine.
    Proxys are also can be set to the request(or globally for all requests), but the plugin will not handle the proxy detection.

    For asynchronousity: the plugin handles all request on separate threads, only the callbacks are dispatched on Unity's main thread from an Update function, so it shouldn't cause major cpu spikes.
     
  43. chaoszombie

    chaoszombie

    Joined:
    Jan 11, 2013
    Posts:
    1
    BestHTTP v1.9.0 (Pro) has too many scripts warning.
    Best HTTP/SecureProtocol/...
     
  44. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @chaoszombie Can you send me what warnings are you receive, what platforms are your using?
    I spent a lot of time to remove all warnings from it, and importing my plugin to a new project, I didn't receive any.
     
  45. ayalasan

    ayalasan

    Joined:
    Dec 10, 2012
    Posts:
    16
    Hey BestHTTP,

    I am working on an Android app built on Unity which communicates with a REST API (from which I have no control). We use BestHttp plugin and all requests are done through https.

    To my surprise, the ssl implementation for Android is very unsecure, since malicious proxy sniffing is pretty straight forward and we are exposed to the man-in-the-middle attack.

    Currently I am trying to implement the CustomVerifier : ICertificateVerifyer to manually validate the Certificates passing through my SSL/TLS connection.

    I was provided with a .pem PUBLIC KEY to validate certificates:

    -----BEGIN PUBLIC KEY-----
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    ...
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    -----END PUBLIC KEY-----

    The problem I have is that in the IsValid method I receive bouncycastle's X509CertificateStructure and I am not sure how to validate them against the PEM public key I have.
    There might be a simple solution for this conversion, but after days of looking at different forums, docs and literature about cryptography I am still lost and cannot figure out how I can check the x509 Certificates validity inside Unity.

    Has anybody had to do something like this before? Any help or code snippet would be inmensly appreciated.

    Thanks!
     
  46. ayalasan

    ayalasan

    Joined:
    Dec 10, 2012
    Posts:
    16
    Hi @codeStrider,

    I am facing a similar issue, where I have to manually implement Certificates Validation in order to prevent malicious packet sniffing (MITM problem). I was wondering if you could share how to effectively check for certificates validity.. I have a .pem Public Key provided by the guys in charge of the API we are connecting with, but I still cannot find a solution to compare X509CertificateStructure with my PEM. Thanks for your time!
     
  47. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @ayalasan This is an area that I'm very inexperienced too, so i can't give a straight answer, but this is a document that i found very useful:
    The Most Dangerous Code in the World: Validating SSL Certificates in Non-Browser Software
    . In section 3.2 it describes the steps to very the server cert.
     
  48. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    hi
    how you are using and maintaining cache ..?
    how you dispose data?
     
  49. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,653
    @aammfee
    Responses that can be served again(have a valid E-Tag, Expires or Age header) will be stored in the cache as distinct files. When a new request is made for that url, the plugin will try to validate it with the server (or just serve it when it's fresh enough - Age and Expires headers are in game here), and if the server replies with a status code 304 (Not Modified) the plugin will load the file and will serve it as it would when it's downloads from the server.

    Cache saved into the folder that unity returns with the Application.persistentDataPath property. This save directory can be changed by setting the HTTPManager.RootCacheFolderProvider delegate.

    Maintenance of the cache is done through the HTTPCacheService's BeginClear and BeginMaintainence functions. You can delete old cache entries and/or keep the cache under a specified size with the BeginMaintainence function.
     
    RazaTech likes this.
  50. just_a_joke

    just_a_joke

    Joined:
    Apr 20, 2015
    Posts:
    13
    Hi @BestHTTP
    Thanks for the previous help. The plugin signalr is working now.
    But now we face another problem, when we try to call server-side code with the complex object type, the call never reach the server which the function on the server-side never fire.

    We use the following code as the for the call method :-

    Code (CSharp):
    1. serverHub.Call("result", resultItem)
    Where the "resultItem" class is as the following :-

    Code (CSharp):
    1. public class resultItem
    2. {
    3.     public Guid id;
    4.     public string connection;
    5.     public List<Answer> answer;
    6.     public List<int> remaining;
    7. }
    We tried serialize the "resultItem" to json string and pass to the Call method as string but the result still same.

    Please advise on this.

    Thanks