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. Kaivaan

    Kaivaan

    Joined:
    Jun 7, 2018
    Posts:
    21
    i've figured out besthttp works out of the box the issue was using system websocket is conflicting with besthttp websocket so in order to fix it i had to change all direct websocket variables to point to BestHTTP.WebSocket.WebSocket e.g
    public BestHTTP.WebSocket.WebSocket ws instead of just
    public websocket ws including all function parameter variables that use websocket
     
  2. topfreegames

    topfreegames

    Joined:
    May 13, 2015
    Posts:
    1
    Hi @BestHTTP

    One of my projects is in Unity 4.7.
    How could I get the old plugin compatible with that Unity version?

    Thanks!
     
  3. BestHTTP

    BestHTTP

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

    If you send me a mail with an invoice id, I can you a few download links to versions that should work with 4.7.
     
  4. unitydave

    unitydave

    Joined:
    Sep 13, 2013
    Posts:
    2
    Hey @BestHTTP
    Love the pro version so far. I'm now extending it's usage for Hololens but I am running into trouble with socket.io connection. Can socket.io be used or should I use another method?

    [UPDATE] exceptional service and response by BestHTTP. Problem connecting solved in v1.10.10
     
    Last edited: Nov 15, 2018
  5. TriggerAndrew

    TriggerAndrew

    Joined:
    Jan 2, 2018
    Posts:
    2
    @BestHTTP Thanks for the quick response on my last question about SignalR. I ended up being able to use your litjsonencoder and didn't have to make my own. I converted the messages in the data field I was getting. From a base 64 stringinto a byte array and parsed it from there into the classes I needed.
     
  6. BestHTTP

    BestHTTP

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

    That bug should be fixed in v.1.10.10. While it's already in the store for review, I sent a download link in private so you don't have to wait for the asset store guys.
     
    unitydave likes this.
  7. YurySedyakin

    YurySedyakin

    Joined:
    Jul 25, 2018
    Posts:
    62
    @BestHTTP Hello. I wonder if you had time to look into request abortion problems I mentioned earlier, is there anything to expect in the new release (looking at the release notes I don't find anything)?
     
  8. lancepriebe

    lancepriebe

    Joined:
    Apr 24, 2016
    Posts:
    3
    I am having an issue with the following errors. Any help would be appreciated.

    Assets/Best HTTP (Pro)/BestHTTP/SignalR/JsonEncoders/DefaultJsonEncoder.cs(12,25): error CS0234: The type or namespace name `Encode' does not exist in the namespace `Json'. Are you missing an assembly reference?
    Assets/Best HTTP (Pro)/BestHTTP/SignalR/JsonEncoders/DefaultJsonEncoder.cs(18,55): error CS0234: The type or namespace name `Decode' does not exist in the namespace `Json'. Are you missing an assembly reference?

    Assets/Best HTTP (Pro)/BestHTTP/SocketIO/JsonEncoders/DefaultJSonEncoder.cs(15,25): error CS0234: The type or namespace name `Decode' does not exist in the namespace `Json'. Are you missing an assembly reference?
    Assets/Best HTTP (Pro)/BestHTTP/SocketIO/JsonEncoders/DefaultJSonEncoder.cs(20,25): error CS0234: The type or namespace name `Encode' does not exist in the namespace `Json'. Are you missing an assembly reference?

    My guess is there is a conflict with Json somewhere with something else. Sadly the only error messages are with Best HTTP.

    Running Unity 2018.2.6f1
     
  9. BestHTTP

    BestHTTP

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

    I had to push this update because of issues under UWP and that issue still not fixed, sorry.
     
  10. BestHTTP

    BestHTTP

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

    In the meantime v1.10.10 got live in the Asset Store too.
     
    unitydave likes this.
  11. BestHTTP

    BestHTTP

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

    Both SignalR's and Socket.IO's DefaultJSonEncoder.cs uses the BestHTTP.JSON namespace though a usage directive, and i see it detects Json as a namespace (The type or namespace name `Encode' does not exist in the namespace `Json'.).

    You can try to replace Assets/Best HTTP (Pro)/BestHTTP/SignalR/JsonEncoders/DefaultJsonEncoder.cs with this:
    Code (CSharp):
    1. #if !BESTHTTP_DISABLE_SIGNALR
    2.  
    3. using System.Collections.Generic;
    4.  
    5. namespace BestHTTP.SignalR.JsonEncoders
    6. {
    7.     public sealed class DefaultJsonEncoder : IJsonEncoder
    8.     {
    9.         public string Encode(object obj)
    10.         {
    11.             return BestHTTP.JSON.Json.Encode(obj);
    12.         }
    13.  
    14.         public IDictionary<string, object> DecodeMessage(string json)
    15.         {
    16.             bool ok = false;
    17.             IDictionary<string, object> result = BestHTTP.JSON.Json.Decode(json, ref ok) as IDictionary<string, object>;
    18.             return ok ? result : null;
    19.         }
    20.     }
    21. }
    22.  
    23. #endif
    and Assets/Best HTTP (Pro)/BestHTTP/SocketIO/JsonEncoders/DefaultJSonEncoder.cs with this:
    Code (CSharp):
    1. #if !BESTHTTP_DISABLE_SOCKETIO
    2.  
    3. using System.Collections.Generic;
    4.  
    5. namespace BestHTTP.SocketIO.JsonEncoders
    6. {
    7.     /// <summary>
    8.     /// The default IJsonEncoder implementation. It's uses the Json class from the BestHTTP.JSON namespace to encode and decode.
    9.     /// </summary>
    10.     public sealed class DefaultJSonEncoder : IJsonEncoder
    11.     {
    12.         public List<object> Decode(string json)
    13.         {
    14.             return BestHTTP.JSON.Json.Decode(json) as List<object>;
    15.         }
    16.  
    17.         public string Encode(List<object> obj)
    18.         {
    19.             return BestHTTP.JSON.Json.Encode(obj);
    20.         }
    21.     }
    22. }
    23.  
    24. #endif
     
  12. olindstrm

    olindstrm

    Joined:
    Aug 8, 2018
    Posts:
    8
    Currently getting this error event on the socket: Code: Internal Message: "Request Finished Successfully, but the server sent an error. Status Code: 526-Origin SSL Certificate Error Message:

    "The SSL certificate presented by the server did not pass validation. This could indicate an expired SSL certificate or a certificate that does not include the requested domain name. Please contact your hosting provider to ensure that an up-to-date and valid SSL certificate issued by a Certificate Authority is configured for this domain name on the origin server."

    This is what the code for opening the socket looks like:

    Code (CSharp):
    1. var queryParams = new ObservableDictionary<string, string> {{"token", token}};
    2.             var options = new SocketOptions {ConnectWith = TransportTypes.WebSocket, AdditionalQueryParams = queryParams, AutoConnect = true};
    3.            
    4.             _manager = new SocketManager(new Uri(_charismaAsset.ServerUrl), options);
    5.             _socket = _manager.Socket;
    Any idea what the culprit may be?
     
  13. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
  14. olindstrm

    olindstrm

    Joined:
    Aug 8, 2018
    Posts:
    8
    @BestHTTP

    Would this have something to do with the SslStream? As far as I'm aware, I can't set UseAlternateSSL by default on the socket manager / socket, but would have to change it to do it automatically in the HTTPrequest class?
     
  15. BestHTTP

    BestHTTP

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

    This issue is out of the sight of the plugin. The server that the plugin is communicating with sends back a proper HTTP response, although the response is about an error: "Request Finished Successfully, but the server sent an error.".
    If the issue would be between the plugin and the server it tries to connect with, it would be a completely different error message, SslStream/alternate ssl wouldn't change anything.
     
  16. BestHTTP

    BestHTTP

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

    A visual approach about what's going on:
    upload_2018-11-8_11-56-28.png
     
  17. olindstrm

    olindstrm

    Joined:
    Aug 8, 2018
    Posts:
    8
    @BestHTTP Ah that makes things a lot clearer!

    Thanks for the quick reply!
     
  18. olindstrm

    olindstrm

    Joined:
    Aug 8, 2018
    Posts:
    8
    So, having dug a bit deeper; sending web requests from chrome works absolutely fine with our certificate chain but for some reason, when doing it using the plugin, we get that same error back. Is there anything, to your knowledge, within the plugin which could cause something like this?

    Code (JavaScript):
    1. //V5CIAjGNzV55hB7zFYAAAFm5kgU4gAABAMARzBFAiA9w0eZrZdE
    2. 8Gk5NsoPtwfKuzMxLHpRB43MTw2HOPemlgIhAIULmKrLCyo4qZyUKDyX00H1ERKY
    3. chfCMD0Pcdx83SLmMAoGCCqGSM49BAMCA0cAMEQCIDM2KH6l75asmX7nrri0OyYX
    4. KnXVmwemF4svzA2oU7TDAiAAjFnNTCMn4jdYuVMTzjZFpa18USaCALeW8s55l8Xe
    5. AQ==
    6. -----END CERTIFICATE-----
    7. subject=/OU=Domain Control Validated/OU=PositiveSSL Multi-Domain/CN=sni28389.cloudflaressl.com
    8. issuer=/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO ECC Domain Validation Secure Server CA 2
    9. ---
    10. No client certificate CA names sent
    11. Peer signing digest: SHA256
    12. Server Temp Key: ECDH, P-256, 256 bits
    13. ---
    14. SSL handshake has read 4609 bytes and written 457 bytes
    15. ---
    16. New, TLSv1/SSLv3, Cipher is ECDHE-ECDSA-AES128-GCM-SHA256
    17. Server public key is 256 bit
    18. Secure Renegotiation IS supported
    19. Compression: NONE
    20. Expansion: NONE
    21. No ALPN negotiated
    22. SSL-Session:
    23.     Protocol  : TLSv1.2
    24.     Cipher    : ECDHE-ECDSA-AES128-GCM-SHA256
    25.     Session-ID: 51E7945C636702037A56B9CF5F161F189B452CD88CB43A5EBF0D4DBDA435E6C6
    26.     Session-ID-ctx:
    27.     Master-Key: D76C5847DAA91C4F6EE3608861B1A2DB5FBADD47440FACF22296DA89ED3AB8FFC8FA269B1BFDC0681F4956CB7A6A8BEA
    28.     Key-Arg   : None
    29.     PSK identity: None
    30.     PSK identity hint: None
    31.     SRP username: None
    32.     TLS session ticket lifetime hint: 64800 (seconds)
    33.     TLS session ticket:
    34.     0000 - 7e 9b b2 82 fb 99 7a e4-9e 7c 15 5f ac 44 15 d8   ~.....z..|._.D..
    35.     0010 - 62 94 a4 28 bc a7 39 36-3f 59 1b 65 f8 ef 9c a5   b..(..96?Y.e....
    36.     0020 - 9f 80 16 18 12 9a c5 16-d6 f5 ce 88 a9 31 6f 24   .............1o$
    37.     0030 - aa 2c 82 84 cd 78 ed e0-13 96 73 2d 93 4b 59 bc   .,...x....s-.KY.
    38.     0040 - c1 23 b5 6c 0b 72 bd 29-23 db 05 50 43 bc 11 d3   .#.l.r.)#..PC...
    39.     0050 - 56 0f f9 9f 07 ae 76 f3-d6 f3 b8 e8 7e 1c 20 84   V.....v.....~. .
    40.     0060 - b2 bf de 0a 9a b3 2e 79-b6 33 08 14 e0 50 80 8d   .......y.3...P..
    41.     0070 - c4 aa 55 60 ae e0 42 9c-cb 19 7c d9 bf 01 6b 1f   ..U`..B...|...k.
    42.     0080 - e4 a4 aa 83 26 36 9d 3d-f0 3c aa ed 31 bb 6f ad   ....&6.=.<..1.o.
    43.     0090 - b8 60 6c 9e 9f 2f 7f c6-99 a4 46 68 9a d4 15 dd   .`l../....Fh....
    44.     00a0 - a2 9e ab 0c 28 40 c6 d7-ca 86 ef a8 a7 29 08 db   ....(@.......)..
    45.     Start Time: 1541689873
    46.     Timeout   : 300 (sec)
    47.     Verify return code: 0 (ok)
    48. ---
     
  19. BestHTTP

    BestHTTP

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

    Can you send me the url of this so i can see it with my own eyes?
     
  20. olindstrm

    olindstrm

    Joined:
    Aug 8, 2018
    Posts:
    8
  21. unitydave

    unitydave

    Joined:
    Sep 13, 2013
    Posts:
    2
    Same interest, did you get sockets working with Hololens?

    [UPDATE] v1.10.10 provided the solution out of the box!
     
    Last edited: Nov 15, 2018
  22. BestHTTP

    BestHTTP

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

    Are you experiencing any issues with the latest version (v1.10.10)? If so, can you send me a repro project?
     
  23. nupur7

    nupur7

    Joined:
    Feb 15, 2017
    Posts:
    9
    Trying to fetch data from azure to unity using websocket. For the same i have used following code:
    Getting exception: An exception has occurred while connecting. Any help thanks in advance.
    EchoTest.PNG WebSocket.PNG
     
  24. BestHTTP

    BestHTTP

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

    Can you show what code you used using my plugin?
     
  25. nupur7

    nupur7

    Joined:
    Feb 15, 2017
    Posts:
    9
    I m using websocket sharp plugin
     
  26. BestHTTP

    BestHTTP

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

    I'm sorry, i think i don't get it. You have problem only with the websocket sharp plugin?
     
  27. nupur7

    nupur7

    Joined:
    Feb 15, 2017
    Posts:
    9
    Actually i m not able to figure out why it is showing exception "An exception has occurred while connecting".
    But when i am trying to connect through local server. I m able to get the data but not with azure cloud.
     
  28. BestHTTP

    BestHTTP

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

    Sorry, but it seems to be quite offtopic here as i'm not the developer of websocket sharp.
     
    Cromfeli likes this.
  29. cruelbob

    cruelbob

    Joined:
    May 26, 2014
    Posts:
    20
    We are using unity 2018.2.14f1 with new runtime. Error isn't very frequent.
     
  30. AT-HuanNguyen

    AT-HuanNguyen

    Joined:
    Jul 7, 2017
    Posts:
    2
    Hi, I am having an issue when connecting to my socket.io server with custom namespaces, the server cannot receive my connection from unity using BestHTTP, but when I try with simple web page everything works fine and when I try to connect with the server at root socket from BestHTTP everything works fine too.
    This is my code to connect server

    Code (CSharp):
    1. [ContextMenu("Connect socket")]
    2.     public void ConnectSocketIO()
    3.     {
    4.         SocketOptions options = new SocketOptions();
    5.         options.AutoConnect = true;
    6.         //
    7.         m_SocketManager = new SocketManager(new Uri("http://localhost:3001/socket.io/"),options);
    8.         Socket customSocket = m_SocketManager["/bkb"];
    9.         customSocket.On(SocketIOEventTypes.Connect,((socket, packet, args) =>
    10.         {
    11.             Debug.LogError("bkb connect");
    12.         }));
    13. //        customSocket.Manager.Open();
    14. //        m_SocketManager.Open();
    15.     }
    Thank you
     
  31. BestHTTP

    BestHTTP

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

    Thanks for the additional information, i will try to reproduce it.
     
  32. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
    @AT-HuanNguyen

    I used this code on client side:
    Code (CSharp):
    1. [ContextMenu("Connect socket")]
    2. public void ConnectSocketIO()
    3. {
    4.     SocketOptions options = new SocketOptions();
    5.     options.AutoConnect = true;
    6.     //
    7.     var m_SocketManager = new SocketManager(new Uri("http://localhost:3001/socket.io/"), options);
    8.     Socket customSocket = m_SocketManager["/bkb"];
    9.     customSocket.On(SocketIOEventTypes.Connect, ((socket, packet, args) =>
    10.     {
    11.         Debug.Log("bkb connect");
    12.         socket.Emit("testmsg", "message from client");
    13.     }));
    14.  
    15.     customSocket.On("bkb_message", (socket, packet, args) =>
    16.     {
    17.         Debug.Log("bkb_message: " + args[0].ToString());
    18.     });
    19. }
    And this for the server:
    Code (JavaScript):
    1. var app = require('http').createServer(handler)
    2. var io = require('socket.io')(app);
    3. var fs = require('fs');
    4.  
    5. app.listen(3001);
    6.  
    7. function handler(req, res) {
    8.     fs.readFile(__dirname + '/index.html',
    9.         function (err, data) {
    10.             if (err) {
    11.                 res.writeHead(500);
    12.                 return res.end('Error loading index.html');
    13.             }
    14.  
    15.             res.writeHead(200);
    16.             res.end(data);
    17.         });
    18. }
    19.  
    20. var nsp = io.of('/bkb');
    21. nsp.on('connection', function (socket) {
    22.     console.log('/bkb - ' + socket.id + ' connected!');
    23.     socket.emit("bkb_message", "message from server");
    24.  
    25.     socket.on("testmsg", function (msg) {
    26.         console.log('testmsg: ' + msg);
    27.     });
    28. });
    And it connected the first time:
    upload_2018-11-15_20-29-41.png
     
  33. AT-HuanNguyen

    AT-HuanNguyen

    Joined:
    Jul 7, 2017
    Posts:
    2
    Thanks, it works like a charm, thank you for quick reply :)
     
  34. reddy36996

    reddy36996

    Joined:
    Jan 10, 2016
    Posts:
    19
    Hi @BestHTTP,

    I recently added new feature to my project in webGL. I'm changing Cookie value in CookieJar at runtime. It is working for android/iOS platforms but for webGL i'm not able to build. I get the error namespace BestHTTP.Cookies doesn't exist.
    I read the docs, it says it is not supported in webGL but in latest update there is partial support for Cookies. I couldn't find any information regarding that in the docs. So is it possible in webGL?

    Thanks
     
  35. reddy36996

    reddy36996

    Joined:
    Jan 10, 2016
    Posts:
    19
    My code is below for reference. There's only one cookie which i want to be able to read and write at runtime at any point in webGL.
    Code (CSharp):
    1.         public void SetCookie(string key, string value)
    2.         {
    3. #if !UNITY_WEBGL
    4.             Cookie cookie = new Cookie(key, value);
    5.             CookieJar.Clear();
    6.             CookieJar.Set(cookie);
    7. #endif
    8.         }
    9.  
    10.         public string GetCookie(string key, string defaultValue = "")
    11.         {
    12. #if !UNITY_WEBGL
    13.             foreach (var cookie in CookieJar.GetAll())
    14.             {
    15.                 if (cookie.Name.Equals(key))
    16.                     return cookie.Value;
    17.             }
    18. #endif
    19.             return defaultValue;
    20.         }
     
  36. BestHTTP

    BestHTTP

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

    Cookie support under WebGL is a little experimental in the latest version, although it should compile just fine. Are you sure you are using the latest version (v1.10.10) of the plugin?
     
  37. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    There is a serious problem we couldn't solve.

    Our client has latest version BestHTTP, and server is Socket.io.

    1. Server just serves on websocket, no long polling, no handshake upgrade.
    2. Client is set like,
    options.ConnectWith = BestHTTP.SocketIO.Transports.TransportTypes.WebSocket;

    It works like a charm for all over the world.

    But just with O2 UK ISP has a problem with it. ( maybe there are more.. ), the problem is Bad Request error.

    1. When we check on O2, https://websocketstest.com/ returns 100% perfect results.
    2. When we're trying to connect with js version of socket.io client with websocket only option, no problem!.
    3. But BestHTTP can not connect and throws "Bad Request " error.

    So, do you have any idea why this problem may happen ?
     
  38. BestHTTP

    BestHTTP

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

    It's possible that O2 modifies requests and they will fail on the server, or even blocks the requests on its own.
    It would be good to have at least detailed logs about the failing request/response, but the best would be logs from the server printing out everything about the wrong request.
     
  39. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    As i said, js version of socket.io client can connect flawlessly. and the , o2 https://websocketstest.com/ returns 100% perfect results.

    That's why i focus on besthttp plugin. i can handle the server response but would you guide me how to get request ( besthttp) logs ? ( it says 400 Bad Request Error, if it's what you want )

    Thank you :)
     
  40. BestHTTP

    BestHTTP

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

    I know what the plugin sends out, but I don't know what the server receives. The it works fine outside of O2, something is happening between the client and server when request is sent from O2's network.
    Only the server know what it receives, that's why a server log / or a request dump would be the best, or a server log about the error - about the 'why?' it's a bad request.
    Logs from the client might be helpful too, you can set the plugin's log level to verbose:
    Code (CSharp):
    1. BestHTTP.HTTPManager.Logger.Level = BestHTTP.Logger.Loglevels.All;
     
  41. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31

    Extremely strange problem,

    1 - As i said i can connect to the server via socket.io client ( js ) on UK O2 ISP.

    2 - But when i tried with best http, this was the loglevels.All export of the library.

    I [SocketManager]: Opening
    I [HTTPUpdateDelegator]: Instance Created!
    D [EventTable]: Call - connecting
    D [HTTPConnection]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Connecting to thedomainnameisreplaced.net:3001
    I [HTTPUpdateDelegator]: Setup done!
    I [HTTPConnection]: Connected to thedomainnameisreplaced.net:3001
    I [HTTPRequest]: Sending request: 'GET /socket.io/?EIO=4&transport=websocket HTTP/1.1'
    I [HTTPRequest]: 'GET /socket.io/?EIO=4&transport=websocket HTTP/1.1' sent out
    D [HTTPConnection]: ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket - Receive - protocol: WebSocket
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Receive. forceReadRawContentLength: '-1', readPayloadData: 'True'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Status Line: 'HTTP/1.1'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - HTTP Version: '1.1'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Status Code: '400'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Status Message: 'Bad Request'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Header - 'Content-Type': 'application/json'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Header - 'Access-Control-Allow-Origin': '*'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Header - 'Date': 'Tue, 20 Nov 2018 18:39:16 GMT'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - Header - 'Transfer-Encoding': 'chunked'
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - ReadChunked - hasContentLengthHeader: False, contentLengthHeader: realLength: 0
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - chunkLength: 34
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - chunkLength: 0
    D [HTTPResponse]: 'ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket' - ReadPayload Finished!
    D [HTTPConnection]: ws://thedomainnameisreplaced.net:3001/socket.io/?EIO=4&transport=websocket - Receive - Finished Successfully!
    D [EventTable]: Call - error
    Request Finished Successfully, but the server sent an error. Status Code: 400-Bad Request Message: {"code":3,"message":"Bad request"}

    2 - At server nothing is triggered, no socket.io middleware ( io.use(), no error or connect_error ) but just origin listener triggers with asterisks * .

    io.origins((origin, callback) => {
    console.log(origin); // -> *
    callback(null, true);
    });

    3 - My conclusion, yes something strange with UK O2 Websocket transfer but some how, the native plugin of socket.io-client (js) can handle it, but not BestHttp.

    Do you have any idea to solve this problem ?

    Thank you.


     
  42. BestHTTP

    BestHTTP

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

    We now know that the request reached the server as the response is a socket.io/engine.io error ({"code":3,"message":"Bad request"}).
    What we need is the relevant part of the server log. You can set the DEBUG environment variable for engine.io (see engine.io's Debug/Logging section) and wait for a bad request.

    What version of socket.io are you using? Are you sure that outside of O2 you can connect to your server with the plugin?
     
  43. cemozturk

    cemozturk

    Joined:
    Sep 27, 2015
    Posts:
    31
    1. There are thousands of players playing around the world. ( outside O2 )
    2. I'm using the latest version of socket.io
    3. I can connect to the server with socket.io client ( JS ) inside O2
    4. These are the engine.io debug logs,

    This is the socket.io js client inside O2 UK or BestHTTP outside O2 UK

    engine handshaking client "k-KLgtn5YNTbIFYbAAAA" +0ms
    engine:socket sending packet "open" ({"sid":"k-KLgtn5YNTbIFYbAAAA","upgrades":[],"pingInterval":10000,"pingTimeout":20000}) +0ms
    engine:socket flushing buffer to transport +0ms
    engine:ws writing "0{"sid":"k-KLgtn5YNTbIFYbAAAA","upgrades":[],"pingInterval":10000,"pingTimeout":20000}" +0ms
    engine:socket sending packet "message" (0) +2ms
    engine:transport setting request +0ms
    engine:socket flushing buffer to transport +3ms
    engine:ws writing "40" +4ms

    This is the best http inside O2 UK ( just 3 lines )

    engine intercepting request for path "/socket.io/" +5m
    engine handling "GET" http request "/socket.io/?EIO=4&transport=websocket" +0ms
    engine handshaking client "VChjUoLByFVt2LDvAAAB" +0ms

    Notes,

    1. I'm not using long polling, just websocket.
    2. No upgradeAllowed, no Cookies in socket.io server.

    var io = require('socket.io')(3001,
    {
    pingTimeout: 20000,
    pingInterval: 10000,
    transports:['websocket'],
    allowUpgrades: false,
    cookie: false
    });

    3. This is the O2 / non-O2 working js client line
    var socket = io("http://domainisreplaced.net:3001", { transports:['websocket'] ,autoConnect: false, reconnection: false, 'forceNew': true });

    4. This is the non-O2 working besthttp property, in O2 fails.
    options.ConnectWith = BestHTTP.SocketIO.Transports.TransportTypes.WebSocket;

    So do you have any idea ?

    Regards
     
    Last edited: Nov 21, 2018
  44. andywatts

    andywatts

    Joined:
    Sep 19, 2015
    Posts:
    110
    Any way to SetHeader with a WebSocket?

    I want to send a JWT token in the header to my server.
     
  45. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,663
  46. BestHTTP

    BestHTTP

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

    On non-webgl platforms you can access the internal http request:
    Code (CSharp):
    1. webSocket = new WebSocket(new Uri("..."));
    2. #if !UNITY_WEBGL || UNITY_EDITOR
    3. string jwtToken = "......";
    4. webSocket.InternalRequest.AddHeader("Authorization", "Bearer " + jwtToken);
    5. #endif
     
    andywatts likes this.
  47. EmileDevelopers

    EmileDevelopers

    Joined:
    May 5, 2017
    Posts:
    2
    Hi, we're planning to buy this today but we need to make sure it will work for our situation. We're needing a new way to do web requests as they are blocked by the proxy in the schools we're selling our product to. They have a firewall named Smoothwall and they use Kerberos for authentication. Our current attempts give us 407 errors, I see on the page it says you have proxy support, will this plugin work?
     
  48. BestHTTP

    BestHTTP

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

    Kereberos authentication isn't supported, only basic and digest.
     
  49. EmileDevelopers

    EmileDevelopers

    Joined:
    May 5, 2017
    Posts:
    2
    Hi, so there is no way around this? The firewall support have said we just need to supply default credentials but we're really unsure of what to do with that.
     
  50. BestHTTP

    BestHTTP

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

    If something supports kerberos then yes, it's easy. But under the hood, it's a complicated protocol.