Search Unity

Best HTTP Released

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

  1. BestHTTP

    BestHTTP

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

    I'm not sure about this. There's an HTTPManager.DefaultClientCredentialsProvider that expects an object that implements the Org.BouncyCastle.Crypto.Tls.IClientCredentialsProvider interface:
    Code (CSharp):
    1. public class TestClientCredentialsProvider : Org.BouncyCastle.Crypto.Tls.IClientCredentialsProvider
    2. {
    3.     public TlsCredentials GetClientCredentials(TlsContext context, CertificateRequest certificateRequest)
    4.     {
    5.         throw new NotImplementedException();
    6.     }
    7. }
    8.  
    9. HTTPManager.DefaultClientCredentialsProvider = new TestClientCredentialsProvider();
    But, GetClientCredentials is called when the server sends a certificate request to the client.
     
  2. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    Ok i will dig it, also what i see is, ssl/tls connection a little bit slower than regular connection, do you have any idea about that ?
     
  3. BestHTTP

    BestHTTP

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

    The whole TLS layer is written in c#, so yes, it's slower than the plaintext http.
     
  4. Uli_Okm

    Uli_Okm

    Joined:
    Jul 10, 2012
    Posts:
    95
    Hello @BestHTTP ,
    I'm currently trying to upload some data to a s3 bucket and amazon authorization headers are really a pain to deal with.
    So using BestHTTP i'm sending a PUT request correctly setting all headers I need, but when I receive the response I'm seeing that these headers:

    Code (CSharp):
    1. Accept-Encoding: gzip, identity
    2. Connection: Keep-Alive, TE
    3. TE: identity
    4. User-Agent: BestHTTP
    5. Content-Length: 98
    Are being automatically added to my request. Is there a way to avoid this, removing these headers?
    Because the way s3 Authorization deals explicitly needs some headers and only them (for example, Content-Length needs to be lowercase, etc)

    Thanks
     
  5. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Uli_Okm

    Can you link the documentation?
    As far as I can remember, additional headers can be there (otherwise it wouldn't be usable through XmlHTTPRequests), you just have to calculate the signature based on a fix set of headers. Casing can be the same: it can be upper case, but you have to calculate the signature with lower cased headers.
     
  6. Uli_Okm

    Uli_Okm

    Joined:
    Jul 10, 2012
    Posts:
    95
    Yep. Thanks for pointing this. It was indeed only the upper/lowercasing mismatch
     
  7. zubius

    zubius

    Joined:
    Sep 12, 2018
    Posts:
    5
    Hello @BestHTTP
    We are using Socket.io for our project with python server. We've encountered and issue with web socket. For a some long time RequestQueue in HTTPManager.cs starts to enlarge. With about 1500 elements in RequestQueue, Unity Editor dramatically drops fps and BestHTTP take about 75% of CPU according to editor profiler.
     
    Last edited: Oct 2, 2018
  8. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @zubius

    Can you share how you are using the plugin? How websocket connections are you have in parallel?
    Websocket is one connection only, it can't produce a lot of requests. Are you trying to send out HTTPRequests?
     
  9. zubius

    zubius

    Joined:
    Sep 12, 2018
    Posts:
    5
    Code (CSharp):
    1.  
    2. SocketOptions options = new SocketOptions ();
    3. options.ConnectWith = TransportTypes.Polling;
    4. options.Reconnection = true;
    5. options.AutoConnect = true;
    6. options.ReconnectionDelayMax = TimeSpan.FromSeconds (1f);
    7.  
    8. Manager = new SocketManager (new System.Uri (Url), options);
    9.  
    10. foreach (var eventName in Names)
    11. {
    12.        SioSocket.On (eventName, OnCustomEvent);
    13. }
    14.  
    15. SioSocket.On (SocketIOEventTypes.Disconnect,  OnDisconnect);
    16. SioSocket.On ("reconnecting", OnReconnecting);
    17.  
    18. SioSocket.On (SocketIOEventTypes.Connect,  OnConnect);
    19. SioSocket.On (SocketIOEventTypes.Error,  OnError);
    20.  
    No additional reconnect custom behaviour.

    We use only one web socket. As it can be seen from request stored in queue - it's web socket itself.
     
    Last edited: Oct 2, 2018
  10. Zinios

    Zinios

    Joined:
    Nov 7, 2017
    Posts:
    5
    @BestHTTP First of all really love your plugin it is awesome .

    I am using your download using streaming method to download big files but i get very slow speed what do you suggest me to do to increase speed.I have tested the speed by downloading directly but the speed i get in unity is very slow.I know your plugin makes it work on low priority thread anyway to make a change to work it on high priority thread.Thank you waiting for the reply :)
     
  11. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Zinios

    Using the thread pool i think will only delay a little when the download will start, but after it has no reason to slow down it.
    There are multiple reasons why it can slow. The plugin's default values try to keep the memory consumption on low in expense of download speed. You can increase the StreamFragmentSize and MaxFragmentQueueLength values.
    Another bottleneck is when the connection is a HTTPS one. The TLS encryption/decryption is written entirely in c# and can be quite slow (in exchange for working on all platforms except on WebGL).
     
  12. UglyDuckling

    UglyDuckling

    Joined:
    Mar 18, 2015
    Posts:
    10
    I have a question regarding requests via HTTPS using a development certificate. Is there a way to override the TLS error message when developing locally using a .NET development certificate?

    Currently when i try a request https://localhost:5000/stuff, I get this error message:
    `Request Finished with Error! Internal TLS error, this could be an attack`

    In .NET Core I can do this to ignore the SSL certificate when developing.
    Code (CSharp):
    1.  httpClientBuilder.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler()
    2. {
    3.     ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
    4. });
     
  13. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @UglyDuckling

    By default the plugin ignores certificate errors, so it works with dev. certifications too. I suspect that there might be something else, maybe port 5000 isn't the one that the server is uses for https?

    You can try to set the following in your startup code: BestHTTP.HTTPManager.UseAlternateSSLDefaultValue = false;
    This way the plugin will use the .net framwork's SslStream instead of the bundled BouncyCastle.
     
  14. UglyDuckling

    UglyDuckling

    Joined:
    Mar 18, 2015
    Posts:
    10
    @BestHTTP Thank you for a quick reply. The port is 5001, I misstyped in my question. =)

    I tried UseAlternateSSL = false, but then I get `The authentication or decryption has failed` instead. So I guess we are back to using the default one.

    The attached image show the complete log before the exception. And below you can see the code.

    Code (CSharp):
    1.     var request = new HTTPRequest(new Uri(SettingsManager.instance.serverUrl + "/api/game/create"), (HTTPRequest req, HTTPResponse res) =>
    2.             {
    3.                 LogUtil.LogHttpRequest(req, res);
    4.  
    5.                 if (res == null || res.StatusCode != 200)
    6.                 {
    7.                     onResponse(null, res != null ? res.DataAsText : "Unknown Error");
    8.                     return;
    9.                 }
    10.  
    11.                 var jsonReader = new JsonReader(res.DataAsText);
    12.                 var game = JsonMapper.ToObject<Game>(jsonReader);
    13.  
    14.                 onResponse(game, null);
    15.             });
    16.  
    17.             request.MethodType = HTTPMethods.Post;
    18.             request.FormUsage = HTTPFormUsage.RawJSon;
    19.             request.AddField("playerName", playerName);
    20.  
    21.             HTTPManager.SendRequest(request);
    I'm also using the tool Insomnia for testing the same request, and there it works just fine.

    Currently I can go back to HTTP, but it would be nice to know if I'm doing something wrong.
     

    Attached Files:

    • Log.png
      Log.png
      File size:
      31.2 KB
      Views:
      742
  15. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @UglyDuckling

    I saw recently a certification that had no 'Digital Signature' flag in its 'Key Usage' extension forcing BouncyCastle to fail. That certificate worked in browsers too, only BC was too picky about it. It can be a similar or the same issue.
     
    UglyDuckling likes this.
  16. Ginxx009

    Ginxx009

    Joined:
    Sep 11, 2016
    Posts:
    89
    Hello BestHttp . I just want to ask how can i make the HTTPResponse DataAsText to null like

    (HTTPResponse response)
    response.DataAsText = null;

    But it's giving me an error saying cannot be assigned -- it is read only
     
  17. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Ginxx009

    DataAsText is read-only because it's just a shortcut to try to convert the downloaded data (stored in the byte[] Data property) to an utf8 string:
    Code (CSharp):
    1. public string DataAsText
    2. {
    3.     get
    4.     {
    5.         if (Data == null)
    6.             return string.Empty;
    7.  
    8.         if (!string.IsNullOrEmpty(dataAsText))
    9.             return dataAsText;
    10.  
    11.         return dataAsText = Encoding.UTF8.GetString(Data, 0, Data.Length);
    12.     }
    13. }
     
  18. Kaivaan

    Kaivaan

    Joined:
    Jun 7, 2018
    Posts:
    24
    error: Code: Internal Message: "Remote server closed the connection before sending response header
    c#
    Code (CSharp):
    1.     private SocketManager Manager;
    2.     void Start()
    3.     {
    4.         // The current state is Login
    5.  
    6.  
    7.         // Change an option to show how it should be done
    8.         SocketOptions options = new SocketOptions();
    9.         options.AutoConnect = false;
    10.         options.ConnectWith = BestHTTP.SocketIO.Transports.TransportTypes.WebSocket;
    11.         options.Reconnection = true;
    12.  
    13.         // Create the Socket.IO manager
    14.         Manager = new SocketManager(new Uri(ConstantUtilities.SitePathSocket), options);
    15.  
    16.  
    17.  
    18.         // The argument will be an Error object.
    19.         Manager.Socket.On(SocketIOEventTypes.Error, (socket, packet, args) => Debug.LogError(string.Format("Error: {0}", args[0].ToString())));
    20.         Manager.Socket.On(SocketIOEventTypes.Connect, callbak);
    21.  
    22.         Manager.Socket.On("time", (socket, packet, arg) => {
    23.             Debug.LogError("Connected to /");
    24.             //socket.On("count", called);
    25.         });
    26.         Manager.Open();
    27.         // We set SocketOptions' AutoConnmnpmect to false, so we have to call it manually.
    28.         Invoke("Late",2);
    29.     }
    Server.js
    Code (JavaScript):
    1. const express = require('express');
    2. const socketIO = require('socket.io');
    3. const path = require('path');
    4.  
    5. const PORT = process.env.PORT || 3000;
    6. const INDEX = path.join(__dirname, 'index.html');
    7.  
    8. const server = express()
    9.   .use((req, res) => res.send("") )
    10.   .listen(PORT, () => console.log(`Listening on ${ PORT }`));
    11.  
    12.  
    13. const io = socketIO(server);
    14. socketIO({
    15.   transports: ['websocket']
    16. });
    17.  
    18. io.on('connection', (socket) => {
    19.   console.log('Client connected');
    20. // socket.on('disconnect', () => console.log('Client disconnected'));
    21. });
    22. setInterval(() => io.emit('time', new Date().toTimeString()), 1000);
    23.  
    bestHTTP websocket works in websocket version of the server but not the socket.io version on the server
    basically
    • BestHttp socketio connectwith websocket+Server Websocket = GOOD
    • BestHttp socketio connectwith websocket+Server Socket.io= BestHTTP Fails
    • Both Socket io and Websocket works if its html not in Unity.

    this one is the alternative server.js that works with bestHttp
    Code (JavaScript):
    1. 'use strict';
    2.  
    3. const express = require('express');
    4. const SocketServer = require('ws').Server;
    5. const path = require('path');
    6.  
    7. const PORT = process.env.PORT || 3000;
    8. const INDEX = path.join(__dirname, 'index.html');
    9.  
    10. const server = express()
    11.   .use((req, res) => res.sendFile("") )
    12.   .listen(PORT, () => console.log(`Listening on ${ PORT }`));
    13.  
    14. const wss = new SocketServer({ server });
    15.  
    16. wss.on('connection', (ws) => {
    17.   console.log('Client connected');
    18. // ws.on('close', () => console.log('Client disconnected'));
    19. });
    20.  
    21. setInterval(() => {
    22.   wss.clients.forEach((client) => {
    23.     client.send(new Date().toTimeString());
    24.   });
    25. }, 1000);
     
    Last edited: Oct 18, 2018
  19. Markstam291

    Markstam291

    Joined:
    Mar 23, 2015
    Posts:
    12
    Hello all!
    I use BestHttp pro ver 1.10.2 to try build UWP PC and Hololens and see many error like this:

    Best HTTP (Pro)\BestHTTP\PlatformSupport\TcpClient\WinRT\DataReaderWriterStream.cs(18,42): error CS1503: Argument 1: cannot convert from 'Windows.Storage.Streams.IInputStream' to 'DataWriter'
    Best HTTP (Pro)\BestHTTP\PlatformSupport\TcpClient\WinRT\DataReaderWriterStream.cs(93,41): error CS0117: 'DataReader' does not contain a definition for 'FromBuffer'
    Best HTTP (Pro)\BestHTTP\PlatformSupport\IO\FileStream.cs(191,38): error CS1503: Argument 1: cannot convert from 'byte[]' to 'int'
    ................
    upload_2018-10-18_11-22-54.png

    I build on Unity 2017.4.1, maybe wrong config playerSetting.
    Please help me, thanks!
     
  20. BestHTTP

    BestHTTP

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

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Markstam291

    Can you share your build settings and the other settings section under the player settings?
     
  22. Kaivaan

    Kaivaan

    Joined:
    Jun 7, 2018
    Posts:
    24
    no i don't i'm connecting directly to localhost:3000

    i can receive message in unity console it pops up OnMessage coming from bestHttp
    but i can't receive my Debug.LogError("Connected to /"); from unity

    Code (CSharp):
    1.       // The current state is Login
    2.    
    3.  
    4.         // Change an option to show how it should be done
    5.         SocketOptions options = new SocketOptions();
    6.         options.AutoConnect = false;
    7.         options.ConnectWith = BestHTTP.SocketIO.Transports.TransportTypes.WebSocket;
    8.        // options.QueryParamsOnlyForHandshake = false;
    9.        // HTTPManager.UseAlternateSSLDefaultValue = true;
    10.         options.Reconnection = true;
    11.      
    12.       //  options.Timeout = TimeSpan.FromDays(2);//the default is good enough we don't want sockets to last for days only a few seconds default is 200000 ms
    13.         // Create the Socket.IO manager
    14.         Manager = new SocketManager(new Uri(ConstantUtilities.SitePathSocket), options);
    15.  
    16.  
    17.         Manager.Socket.On("time", (socket, packet, arg) => {
    18.             Debug.LogError("Connected to /");
    19.             //socket.On("count", called);
    20.         });
    21.         Manager.Open();
    22.         // We set SocketOptions' AutoConnmnpmect to false, so we have to call it manually.
    23.         Invoke("Late",2);  
     
    Last edited: Oct 18, 2018
  23. Markstam291

    Markstam291

    Joined:
    Mar 23, 2015
    Posts:
    12
    Thank for reply, here my config :D

    upload_2018-10-18_13-41-38.png
    upload_2018-10-18_13-42-45.png
     
  24. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
  25. Kaivaan

    Kaivaan

    Joined:
    Jun 7, 2018
    Posts:
    24
    IT WOKRS thanks a lot also
    i'm going for a web-socket approach can't seam to make socket io to work

    Server.js
    Code (JavaScript):
    1.  
    2. const express = require('express');
    3. const SocketServer = require('ws').Server;
    4. const websocket = require('ws');
    5. const path = require('path');
    6.  
    7. const PORT = process.env.PORT || 3000;
    8. const server = express()
    9.   .use((req, res) => res.send("") )
    10.   .listen(PORT, () => console.log(`Listening on ${ PORT }`));
    11.  
    12. const wss = new SocketServer({ server });
    13.  
    14. wss.on('connection', (ws) => {
    15.  
    16.   console.log('Client connected');
    17.  
    18.   ws.on('close', () => console.log('Client disconnected'));
    19. });
    20.  
    21. setInterval(() => {
    22.   wss.clients.forEach((client) => {
    23.       if(client.readyState==1){
    24.         client.send(new Date().toTimeString());
    25.       }
    26.   });
    27. }, 1000);

    C# code
    Code (CSharp):
    1.     void Start()
    2.     {
    3.         // The current state is Login
    4.  
    5.  
    6.         var webSocket = new WebSocket(new Uri(ConstantUtilities.WebsocketPath));
    7.         webSocket.OnMessage += OnMessage;
    8.         webSocket.OnOpen += OnWebSocketOpen;
    9.         webSocket.OnError += OnError;
    10.         webSocket.Open();
    11.  
    12.     }
    13.  
    14.     private void OnError(WebSocket webSocket, Exception ex)
    15.     {
    16.         Debug.Log(ex.Message);
    17.         // throw new NotImplementedException();
    18.     }
    19.  
    20.     private void OnWebSocketOpen(WebSocket webSocket)
    21.     {
    22.        // throw new NotImplementedException();
    23.     }
    24.  
    25.     private void OnMessage(WebSocket webSocket, string message)
    26.     {
    27.         Debug.Log(message);
    28.    
    29.     }
     
  26. yu-hashimoto

    yu-hashimoto

    Joined:
    Oct 16, 2018
    Posts:
    1
    We would like to connect with SocketCluster. It seems that they need JWT authentication while connecting and do you have any option to connect with JWT, or any sample code to connect with ?
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Markstam291

    Strange, but i couldn't reproduce it. I'm sure i saw those error messages already, but I couldn't recall what setting caused them.
    Could you send me a repro-project?
     
  28. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @yu-hashimoto

    I'm not familiar with SocketCluster, but usually these tokens are sent in an authorization header:
    Code (CSharp):
    1. Uri uri = new Uri("https://myserver.com");
    2. var request = new HTTPRequest(uri, RequestHandler);
    3.  
    4. // Generate token:
    5. string jwToken = "......";
    6.  
    7. request.AddHeader("Authorization", "Bearer " + jwToken);
    8.  
    9. request.Send();
    You can also add a header for a WebSocket request (except under WebGL):
    Code (CSharp):
    1. // Create the WebSocket instance
    2. webSocket = new WebSocket(/*uri: */ new Uri(address), /*origin: */ null, /*protocol: */ null, /*extensions: */ pmc);
    3.  
    4. #if !UNITY_WEBGL || UNITY_EDITOR
    5. string jwToken = "......";
    6. webSocket.InternalRequest.AddHeader("Authorization", "Bearer " + jwToken);
    7. #endif
    Of course, SocketCluster may require a different way to deliver the token.
     
  29. exoter

    exoter

    Joined:
    Apr 25, 2015
    Posts:
    10
    The last version fixed
    • SignalR
      • [Bugfix] It will not try to reconnect after leaving Unity's play mode.
    But this is still an issue with SocketIO
     
  30. cra_unity

    cra_unity

    Joined:
    Mar 27, 2015
    Posts:
    3
    I am trying to use Best HTTP Pro to add SocketIO support to a Unity app on the HoloLens. However, seems like no matter what I do (e.g., polling, web socket), I get a connection time out. Other HTTP requests I make (GETs, POSTs) are working fine using UnityWebRequests. I am using Unity 2018.2.1f1 and Best HTTP Pro v1.10.9.

    Any ideas?
     
  31. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @exoter

    Thanks, I will look for it. What version of Unity are you using?
     
  32. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @cra_unity

    Sending a new version of the plugin in private, please try it out with this one.
     
  33. Markstam291

    Markstam291

    Joined:
    Mar 23, 2015
    Posts:
    12
    Hello, I build success on UWP for PC and Hololens, but when i try connect to socket.io, it not work, it connect time out. I test on editor it work.
    Server need any special config?
    Please help me, thanks!

    Platform:
    Unity free: 2017.4.13f1
    BestHttp Pro version 1.10.9
    My Code:
    upload_2018-10-26_12-33-46.png
    Setting:
    upload_2018-10-26_12-20-50.png
    upload_2018-10-26_12-20-22.png
     
    Last edited: Oct 26, 2018
  34. Kaivaan

    Kaivaan

    Joined:
    Jun 7, 2018
    Posts:
    24
    i'm receiving this error from websocket when i try to use webGL

    Error:

    Assets/Best HTTP (Pro)/Examples/Websocket/WebSocketSample.cs(78,31): error CS1061: Type `WebSocket' does not contain a definition for `OnOpen' and no extension method `OnOpen' of type `WebSocket' could be found. Are you missing an assembly reference?
     
  35. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Kaivaan

    Can you try to reimport the package? It must work out of the box without any errors.
     
  36. YurySedyakin

    YurySedyakin

    Joined:
    Jul 25, 2018
    Posts:
    63
    Hello @BestHTTP . I'm using BestHTTPPro and am observing some misbehavior on both Unity 2017 and 2018.
    Symptoms: create three HTTPRequests to download some large files with streaming. My setup for requests:
    Code (CSharp):
    1.  
    2. HTTPRequest httpRequest = new HTTPRequest(new Uri(url), callback)
    3.             {
    4.                 MethodType = HTTPMethods.Get,
    5.                 IsKeepAlive = true,
    6.                 DisableCache = true,
    7.                 UseStreaming = true,
    8.                 EnableTimoutForStreaming = false, // NOT: YS this one is false by default, it's here to emphasize its importance
    9.                 StreamFragmentSize = this._streamFragmentSize,
    10.                 MaxFragmentQueueLength = this._maxFragmentQueueLength
    11.             };
    12.  
    Now in OnApplicationPause I am aborting all of those requests. As a result some (one, sometimes two) of those requests never finish after aborting them.
    One more thing I noticed is that after aborting they continue to invoke my callback and (at least sometimes) try to deliver fragments to me. Because my callback knows that the corresponding request has been aborted it doesn't read fragments (no call to GetStreamedFragments()). This seems to make the request hang forever. As a workaround I tried doing GetStreamedFragments() but simply discard them - this isn't enough. I ALSO must wait a frame before invoking Abort() instead of calling Abort() in OnApplicationPause. These two workarounds SEEM to fix the issue, but I'd much more prefer a proper fix from the author
     
  37. CR_Admin

    CR_Admin

    Joined:
    Sep 8, 2017
    Posts:
    4
    Hey all,

    I recently purchased BestHTTP in order to implement socket communication between our app and backend. However, when added to the project, I get a massive amount of import type conflict warnings. As far as I can tell, Gamesparks uses BestHTTP as their backend solution and its implementation is causing the conflicts. That seems... wrong.

    Example:
    Assets/Best HTTP (Pro)/BestHTTP/SecureProtocol/util/io/pem/PemHeader.cs(38,17): warning CS0436: The type `Org.BouncyCastle.Utilities.IO.Pem.PemHeader' conflicts with the imported type of same name'. Ignoring the imported type definition

    There are over 500 warnings and I'd hate for the Gamesparks BestHTTP version to "win out" on the import over the newest version I just paid for/downloaded.

    Any suggestions on how to resolve this?
     
  38. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
  39. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @CR_Admin

    I think they are using BouncyCastle too for HTTPS. You can disable the plugin's BouncyCastle integration by adding BESTHTTP_DISABLE_ALTERNATE_SSL to your Scripting Define Symbols. This way the plugin will use the .net framework's SslStream instead and your project should compile.
     
  40. Kaivaan

    Kaivaan

    Joined:
    Jun 7, 2018
    Posts:
    24
    sadly no avail i don't know why webgl is failing. i noticed that during the import i received failed assertion webgl.
    using 2018.2.14f1
     
    Last edited: Oct 31, 2018
  41. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Kaivaan

    Just tried to import the package in multiple ways without any errors. Can you send me a repro-project?
     
  42. TriggerAndrew

    TriggerAndrew

    Joined:
    Jan 2, 2018
    Posts:
    2
    Hi there, I recently purchased BestHTTP for Signalr Core integration in my application. The plugin is setup very nicely and I'm able to make my connection and see that I am receiving messages just fine.

    Signalr is new to me so I'm not sure if I'm setting something up incorrectly but I wanted to ask about an issue I've been having. It turns out the server that I need to access outputs data using Google Proto Buffers (proto3), not JSON, and I was hoping you had some advice about connecting the two. I have my .proto setup correctly I believe, but I'm not fully sure how to hook the two together. I know that there is MessagePack protocol for Core which hasn't yet been supported I believe by your plugin, but I'm not sure if that's relevant to what I am trying to do.

    I'm not sure if this is out of scope of what you're planning on supporting with this plugin, but I thought I'd ask.
     
  43. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @unity_oOBeDOHIOmKE2g

    I'm still behind my schedule so to add a proto buffers and/or message pack implementation. But, here's the skeleton of the two classes that must be implemented to use a new protocol with SignalR Core:
    Code (CSharp):
    1. public sealed class ProtoBufferEncoder : BestHTTP.SignalRCore.IEncoder
    2. {
    3.     public string Name { get { return "protobuffer"; } }
    4.  
    5.     public object ConvertTo(Type toType, object obj)
    6.     {
    7.         throw new NotImplementedException();
    8.     }
    9.  
    10.     public T DecodeAs<T>(string text)
    11.     {
    12.         throw new NotImplementedException();
    13.     }
    14.  
    15.     public T DecodeAs<T>(byte[] data)
    16.     {
    17.         throw new NotImplementedException();
    18.     }
    19.  
    20.     public byte[] EncodeAsBinary<T>(T value)
    21.     {
    22.         throw new NotImplementedException();
    23.     }
    24.  
    25.     public string EncodeAsText<T>(T value)
    26.     {
    27.         throw new NotImplementedException();
    28.     }
    29. }
    30.  
    31. public sealed class ProtoBufferProtocol : BestHTTP.SignalRCore.IProtocol
    32. {
    33.     public TransferModes Type { get { return TransferModes.Binary; } }
    34.     public IEncoder Encoder { get; private set; }
    35.     public HubConnection Connection { get; set; }
    36.  
    37.     public ProtoBufferProtocol()
    38.     {
    39.         this.Encoder = new ProtoBufferEncoder();
    40.     }
    41.  
    42.     /// <summary>
    43.     /// Convert a value to the given type.
    44.     /// </summary>
    45.     public object ConvertTo(Type toType, object obj)
    46.     {
    47.         throw new NotImplementedException();
    48.     }
    49.  
    50.     /// <summary>
    51.     /// This function must return the encoded representation of the given message.
    52.     /// </summary>
    53.     public byte[] EncodeMessage(Message message)
    54.     {
    55.         throw new NotImplementedException();
    56.     }
    57.  
    58.     /// <summary>
    59.     /// This function must convert all element in the arguments array to the corresponding type from the argTypes array.
    60.     /// </summary>
    61.     public object[] GetRealArguments(Type[] argTypes, object[] arguments)
    62.     {
    63.         throw new NotImplementedException();
    64.     }
    65.  
    66.     /// <summary>
    67.     /// This function must parse binary representation of the messages into the list of Messages.
    68.     /// </summary>
    69.     public void ParseMessages(string data, ref List<Message> messages)
    70.     {
    71.         throw new NotImplementedException();
    72.     }
    73.  
    74.     /// <summary>
    75.     /// This function must parse textual representation of the messages into the list of Messages.
    76.     /// </summary>
    77.     public void ParseMessages(byte[] data, ref List<Message> messages)
    78.     {
    79.         throw new NotImplementedException();
    80.     }
    81. }
    Then you can use it when you create a new HubConnection:
    Code (CSharp):
    1. var hub = new HubConnection(new Uri("https://myserver/myHub"), new ProtoBufferProtocol());/code]
     
  44. Peepijeep

    Peepijeep

    Joined:
    Nov 1, 2018
    Posts:
    4
    Hello,
    I am very interested in your great plugin.
    Does that work with WebSockets and Hololens (UWP)?
    I used several WebSocket and Socket.IO Plugins for Unity/UWP, and most didn't work for me :(
     
  45. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
  46. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    I'm interested too in running BestHTTP on UWP.
     
  47. Peepijeep

    Peepijeep

    Joined:
    Nov 1, 2018
    Posts:
    4
    I tested 2 other free Plugins for Websockets --> None worked for Hololens / UWP.

    But this one works! Thanks! :D
    I am so happy!
     
    Cromfeli likes this.
  48. Peepijeep

    Peepijeep

    Joined:
    Nov 1, 2018
    Posts:
    4
    Did it worked for you?
     
  49. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    I'm going to test
     
  50. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    Uploaded v1.10.10 to the Asset Store, I hope it will be released in a few days.

    Release notes of the update:

    1.10.10 (2018.11.04)
    • General
      • [Improvement] New demo page added: https://besthttpdemosite.azurewebsites.net/
      • [Bugfix] One of HTTProxy's constructor didn't use a parameter to set the correct value
      • [Improvement] Improved connection handling and code quality for the UWP connection layer
    • WebGL
      • [New Feature] Partial cookie support added (cookies are managed by the browser, but the plugin is able to read and write them)
      • [New Feature] Read and write cookie support added
      • [New Feature] HTTPRequest has a new WithCredentials property
      • [Improvement] More requests will be 'simple' to do not require a preflight request
    • SignalRCore
      • [New Feature] Added client-sent ping messages
      • [Improvement] New example added
    • WebSockets
      • [Improvement] Increased the limit of the per-message deflate extension's minDataLengthToCompress parameter.
      • [Improvement] [WebGL] Client-side generated status code of 1006 is treated as an error now to match non-webgl behavior.
    Also, there's a new demo page for the plugin: https://besthttpdemosite.azurewebsites.net/
    This is a WebGL build (built with Unity 2018.2) instead of the (very) old webplayer one.
    Why the old SignalR protocol is still supported, the official implementation received its last update recently. All the samples are still there in the package but I don't wanted to set up another server just to showcase it. Instead, the new SignalR Core received its long awaited sample!
     
    Markstam291 and TriggerAndrew like this.