Search Unity

Best HTTP Released

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

  1. waldgeist

    waldgeist

    Joined:
    May 6, 2017
    Posts:
    55
    Thanks for the info!
     
  2. DennisATA

    DennisATA

    Joined:
    Feb 5, 2016
    Posts:
    3
    Hello,

    It seems the current TLS SNI value pulls from the host of the request URI. However, this may not necessarily be ideal in the case where we specify the IP address as the host directly, and use the "Host" header to tell the web server which virtual host to serve. From browsing the code, it seems we can add our own hostname in HTTPConnection.Connect where it creates the LegacyTLS client. However, I just wanted to check whether there is any other way that I missed which doesn't require a change to the library code?

    Thanks,
    Dennis
     
  3. BestHTTP

    BestHTTP

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

    Yes, the plugin will start a new thread to send the request and receive the response, but to avoid threading issues, these callbacks are dispatched from Unity's main thread (from a regular Update event).
     
    Dan2013 likes this.
  4. BestHTTP

    BestHTTP

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

    SNI is sent out right after the TCP connection is established and before any header can be sent out. The server might choose the server certificate based on this SNI (if there are more than one hosts), it can't use the Host header for this.
    (Of course when the request is read by the server, it will make its chose based on the Host header, but this will happen in a later stage.)

    You might be right however that the plugin shouldn't send IP addresses.

    What would be your use case to change the sent hostname? Is it causing errors for you?
     
  5. DennisATA

    DennisATA

    Joined:
    Feb 5, 2016
    Posts:
    3
    In normal circumstances, our application connects to our servers using domain names (in which case the current SNI works fine). However, in the case we cannot properly resolve or connect to the servers through domain name we have a "fallback" mechanism to attempt connection through a list of IP addresses. When this happens, we can use the Host header to tell the web server which virtual host to serve, but with the current code in the library we cannot override the TLS SNI to tell the web server which SSL cert to use. There aren't any errors, but it results in unexpected SSL certificates being used as the server can't properly determine the correct one to use.

    I think ideally there'd be a way to set a custom SNI in HTTPRequest.

    Yeah as far as I understand the RFC, literal IP addresses shouldn't be sent in SNI.

    Regards,
    Dennis
     
  6. BestHTTP

    BestHTTP

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

    Sent a link in private to a new package. With this new package no IP addresses should be sent to the server.
     
    DennisATA likes this.
  7. shb

    shb

    Joined:
    Oct 7, 2012
    Posts:
    23
    Hi, Here's my situation.

    -Client : Unity 2017 , Best Http pro using Socket.IO module. .NET4.6 Experimental , WebGL build.
    -Servier : node.js with socket.io

    Everything works fine when scripting runtime is not 4.6 .
    But when I run WebGL build using .NET4.6 , the connection to the server fails with the error below.

    blob:http://localhost:3000/a908ebf5-f2dc-4205-afc9-4eb23a09abf6:2 Ex [PollingTransport]: ParseResponse - Message: 1: The type initializer for 'System.Globalization.CharUnicodeInfo' threw an exception.
    2: The type initializer for 'System.Globalization.CharUnicodeInfo' threw an exception. StackTrace:

    (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/WebGL/runtime/DebugBindings.gen.cpp Line: 51)

    it works fine on Editor, but fails on WebGL build.
    I tried Unity 2018 beta latest version, but got same error.

    Is there any extra step for using Socket.IO on .NET4.6 as scripting runtime?
     
  8. BestHTTP

    BestHTTP

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

    This must be a bug in the new experimental runtime. I already reported multiple one, but this is a new one to me. You should use the report bug feature through the Unity editor (Help\Report a bug... menu item) and upload a repro-project.
     
    knobby67 likes this.
  9. pflamant

    pflamant

    Joined:
    Dec 7, 2017
    Posts:
    4
    Hello,
    I have the same error as unity_surviver, do you know when the next version will be released?
    I also have another error when I try to compile my project for Hololens:
    Do you have any clue where that might come from?

    I'm using Unity 2017.3.0f3
     
  10. BestHTTP

    BestHTTP

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

    Sent a download link in private for a wsa dll for Unity 2017.3.

    I will push a bugfix release to the Asset Store as soon as I could win over my flu. :/
     
  11. effulgent

    effulgent

    Joined:
    Oct 13, 2014
    Posts:
    3
    Hello, thank you @BestHTTP for the awesome plugin!

    Recently our clients requested us to support Microsoft NTLM proxy. As far as I know, it's not supported by BestHTTP yet. So, the question is: do you plan to add it to the lib or maybe there is an approach we can use to write it ourselves (using your code)?

    Thanks!
     
    Last edited: Feb 28, 2018
  12. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
  13. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    @BestHTTP
    Hello, How can i send both rawData (which is json) as well as a FileStream at the same time?
    Here is my current code but seems like rawData doesnt reach the backend.

    As you can see im sending both a json request body and a file at the same time.

    Please advise

    Code (CSharp):
    1. request.RawData = Encoding.UTF8.GetBytes(json);
    2.  
    3.  
    4. request.UploadStream = new FileStream(file.FullName, FileMode.Open);
    5.            
    6.  
    7.  
     
  14. BestHTTP

    BestHTTP

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

    Well, it's on my todo list, but with a quite low priority. NTLM is a very rarely requested feature with high complexity to implement.
     
  15. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    helloworldgames likes this.
  16. BestHTTP

    BestHTTP

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

    You can't mix RawData and UploadStream.
    If you want to send them in one request you may want to use the AddField and AddBinaryData functions of the HTTPRequest.
     
    jGate99 likes this.
  17. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    https://developers.google.com/youtube/v3/docs/videos/insert

    I'm actually uploading a video to youtube api which require file as well as json structure.
    how can i send that json via addField?


    2
    UploadStream uses FileStream so its good to deal with large file sizes but addBinary uses binary data which means ill hv to load whole file in memory at once which is not good for uploading videos.
     
  18. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    @BestHTTP
    Here is the code which im unable to merge, your advise can be a life saver as this is just killing me.

    Code (CSharp):
    1.      string json = JsonMapper.ToJson(new {
    2.                
    3.                 snippet = new {
    4.                    
    5.                     title = "Test Video",
    6.                     description = "This is a descripton"
    7.                 }
    8.                
    9.  
    10.  
    11.             });
    12.  
    13.        
    14.             request.RawData = Encoding.UTF8.GetBytes(json);
    15.  
    16.             request.UploadStream = new FileStream(file.FullName, FileMode.Open);
    17.            
    18.            
    Thanks
     
  19. BestHTTP

    BestHTTP

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

    That link isn't helpful at all unfortunately, all samples are using a google api implementation for that language/framework, and it doesn't describe what should be sent actually... :/ A proxy capture would be helpful from a working one.

    Because mixing different type of data in an upload can be done with a form, but without any encoding is quite uncommon...

    In your case I would try to do a proof with a small video to prove the theory that how you want to upload it is way youtube really expects the data.
    For this you could create a MemoryStream write the Encoding.UTF8.GetBytes(json) into it, the load file, write that too into the memory stream, then set this stream as the RawData and send the request.
    If it works, a custom stream implementation could be written that can handle data from different sources.
     
  20. BestHTTP

    BestHTTP

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

    The idea of a stream that could read from different sources was quite familiar and yep, I wrote it years ago. It's in the \Best HTTP (Pro)\BestHTTP\Connections\FileConnection.cs, but it's not marked as public. You can make this class public, or you can copy+paste.

    Basically you can pass multiple streams to its constructor, and it will server all of them in the same order as you passed them to the constructor.

    So, using this StreamList class you could write something like this:
    Code (CSharp):
    1. string json = JsonMapper.ToJson(new
    2. {
    3.     snippet = new
    4.     {
    5.  
    6.         title = "Test Video",
    7.         description = "This is a descripton"
    8.     }
    9. });
    10.  
    11. MemoryStream jsonStream = new MemoryStream();
    12.  
    13. var buffer = System.Text.Encoding.UTF8.GetBytes(json);
    14. jsonStream.Write(buffer, 0, buffer.Length);
    15.  
    16. StreamList stream = new StreamList(jsonStream, new FileStream(file.FullName, FileMode.Open));
    17.  
    18. HTTPRequest request = new HTTPRequest(new Uri("http://youtube.com/upload"), HTTPMethods.Put, OnRequestFinished);
    19. request.UploadStream = stream;
    20. request.Send();
    StreamList will serve will read until it can from the first stream then from the second. Because it will read into the buffer that the plugin will pass to its Read function, it will read from the file only the requested amount of bytes not all of them.
     
  21. BestHTTP

    BestHTTP

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

    Although, I have to add a remark, that StreamList isn't a highly tested class. The plugin will use the Read and Dispose functions and Length property by default. These should work fine, but I would implement Seek differently now.
     
  22. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    @BestHTTP

    First of all thank you very much for your detailed reply,
    Youtube api is expecting me to send json in request body (its a POST instead of put),

    however whether i send file or not, it never gets the request body but request is itself successful and an in progress video is created on yourube side.

    However if i send the video via uploadStream, it gets the video and request is a success (but without the json).

    I also tried StreamList with json first video later, and vice verca but it this time neither video nor json got uploaded and response was null too.

    I think, first i should get json in request body via post (whatever is meant by google). So please advise


    Update 2
    Here is python script along with descritption, it went over my head but perhaps you can understand it
    https://developers.google.com/youtube/v3/guides/uploading_a_video

    Update 3
    This is curl based example using resumeable
    https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol
     
    Last edited: Mar 1, 2018
  23. BestHTTP

    BestHTTP

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

    That cURL based protocol description is what we are looking for! As I see it has everything you need to implement it.
    So, first you have to make a POST request with the json and it will send a response with a new url in the Location header.

    With the plugin it would be something like this:
    Code (CSharp):
    1. void StartSession()
    2. {
    3.     // Step 1 - Start a resumable session
    4.  
    5.     var file = new
    6.     {
    7.         FullName = "..."
    8.     };
    9.  
    10.     string json = JsonMapper.ToJson(new { snippet = new { title = "Test Video", description = "This is a descripton" } });
    11.     string url = "https://www.googleapis.com/upload/youtube/v3/videos";
    12.  
    13.     var request = new HTTPRequest(new Uri(url), HTTPMethods.Post, OnStartSessionRequestFinished);
    14.     request.AddHeader("authorization", "auth token");
    15.     request.AddHeader("X-Upload-Content-Length", new FileInfo(file.FullName).Length.ToString());
    16.     request.AddHeader("x-upload-content-type", "video/*");
    17.  
    18.     request.AddHeader("Content-Type", "application/json; charset=utf-8");
    19.     request.RawData = Encoding.UTF8.GetBytes(json);
    20.     // Content-Length will be added by the plugin automatically
    21.  
    22.     // We don't have to follow the redirection
    23.     request.OnBeforeRedirection += CancelRedirection;
    24.  
    25.     request.Send();
    26. }
    27.  
    28. private bool CancelRedirection(HTTPRequest originalRequest, HTTPResponse response, Uri redirectUri)
    29. {
    30.     // Just cancel the redirect
    31.     return false;
    32. }
    33.  
    34. private void OnStartSessionRequestFinished(HTTPRequest req, HTTPResponse resp)
    35. {
    36.     switch (req.State)
    37.     {
    38.         // The request finished without any problem.
    39.         case HTTPRequestStates.Finished:
    40.             if (resp.IsSuccess)
    41.             {
    42.                 // Step 2 - Save the resumable session URI
    43.  
    44.                 string newUrl = resp.GetFirstHeaderValue("Location");
    45.                 Debug.Log("new URL: " + newUrl);
    46.  
    47.                 UploadVideo(newUrl);
    48.             }
    49.             else // Internal server error?
    50.                 Debug.LogWarning(string.Format("Request Finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
    51.                                                         resp.StatusCode,
    52.                                                         resp.Message,
    53.                                                         resp.DataAsText));
    54.             break;
    55.  
    56.         // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
    57.         case HTTPRequestStates.Error:
    58.             Debug.LogWarning("Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
    59.             break;
    60.  
    61.         // The request aborted, initiated by the user.
    62.         case HTTPRequestStates.Aborted:
    63.             Debug.LogWarning("Request Aborted!");
    64.             break;
    65.  
    66.         // Connecting to the server is timed out.
    67.         case HTTPRequestStates.ConnectionTimedOut:
    68.             Debug.LogError("Connection Timed Out!");
    69.             break;
    70.  
    71.         // The request didn't finished in the given time.
    72.         case HTTPRequestStates.TimedOut:
    73.             Debug.LogError("Processing the request Timed Out!");
    74.             break;
    75.     }
    76. }
    77.  
    78. void UploadVideo(string url)
    79. {
    80.     // Step 3 - Upload the video file
    81.  
    82.     var file = new
    83.     {
    84.         FullName = "..."
    85.     };
    86.  
    87.     var request = new HTTPRequest(new Uri(url), HTTPMethods.Put, (req, resp) => { });
    88.     request.AddHeader("authorization", "auth token");
    89.     request.AddHeader("X-Upload-Content-Length", new FileInfo(file.FullName).Length.ToString());
    90.     request.AddHeader("x-upload-content-type", "video/*");
    91.  
    92.     request.UploadStream = new FileStream(file.FullName, FileMode.Open);
    93.  
    94.     request.Send();
    95. }
     
    jGate99 and Cromfeli like this.
  24. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    I cant tell you how happy and thankful i am, you are one heck of a great example of plugin developers who go beyond and invest their own precious time to support their customers. God Bless You :)
     
    BestHTTP and Cromfeli like this.
  25. melefans

    melefans

    Joined:
    Aug 1, 2016
    Posts:
    36
    Hello, @BestHTTP
    I have a issue , when the server close connection normally, window edge browser occurs a error.
    besthttp version: 1.10.0.
    Unity webGL Platform.
    firefox and chrome are working.
     
  26. BestHTTP

    BestHTTP

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

    1005 is treated as an error. Are you sending this code directly from your server?
     
  27. melefans

    melefans

    Joined:
    Aug 1, 2016
    Posts:
    36
    Only the server shuts down the socket normally and I don't have anything to do. I use the websocket example to test the same problem, server socket close, Webscoket OnError callback will appear 1005(Edge browser).
     
  28. BestHTTP

    BestHTTP

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

    For normal closure the 1000 code should be used.
    But, anyway I can't remember why I put these codes (1001, 1002, 1003, 1005, 1006, 1009) as errors as this isn't in pair with the behavior of the non-webgl builds... So, sending a new jslib in private if you want to try out a fixed version.
     
  29. creepco

    creepco

    Joined:
    Feb 2, 2015
    Posts:
    8
    Hello,

    I'm posting player info to a Firebase database, and having trouble posting unless sending as raw data:

    public void CreateServerPost(int _level, int _score, string _name)
    {
    MyClass myObject = new MyClass();
    myObject.level = _level;
    myObject.score = _score;
    myObject.playerName = _name;

    string json = JsonUtility.ToJson(myObject);

    HTTPRequest request = new HTTPRequest(new System.Uri("https://myServer.firebaseio.com/Leaders.json"), HTTPMethods.Post, OnRequestFinished);
    request.RawData = Encoding.UTF8.GetBytes(json);

    //rather than raw data, trying to send with name
    //request.AddField("gameSessionInfo", json);

    request.Send();
    }
    The above is successfully sending data to my Firebase database, but I'm not able to name the post. Firebase names the post random gibberish.
    I've tried to send the data using request.AddField (commented out in above code), but I get an error from Firebase saying it's not valid JSON.

    Can someone suggest how I can post my data with a name?

    I'm new to database/Firebase, so forgive me if this is a newbie question.
     
  30. BestHTTP

    BestHTTP

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

    That's clear that you shouldn't use the AddField functions, as the server expect the data as json. AddField would send it url or multipart encoded.

    Is there a documentation for the API (Leaders.json) you are trying to use? If I see what the server expects, I might be able to find out how you should send your data.
     
  31. sumitx

    sumitx

    Joined:
    Mar 16, 2017
    Posts:
    2
    Hi BestHTTP,

    I think in WebGL version, HTTPManager's heartbeat is not run. (Unity Editor version is run heartbeat.)
    So WebSoket will be ping timeout.(I use socket.io)
    Why cause this problem?
     
    Last edited: Mar 12, 2018
  32. BestHTTP

    BestHTTP

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

    Fortunately this is a known issue in the currently released package and will be fixed in the next release. Sent a download link to you in a private message to the new and fixed package.
     
    sumitx likes this.
  33. fafase

    fafase

    Joined:
    Jul 3, 2012
    Posts:
    156
    Hi,

    Does the following:

    Code (CSharp):
    1. request.AddField("name", "Phil");
    2. request.AddField("type", "human");
    3. request.AddBinaryData("image", texture.EncodeToJpg(),"image.png");
    convert to this?

    Code (CSharp):
    1. {
    2.     "name": "Phil",
    3.     "type" : "human",
    4.      "data": // long stream of raw data
    5. }
    I am trying to send an image to a server but it complains that a field is missing. I would need to check with the server guy but maybe I am assuming wrong right from the start.

    Cheers
     
  34. BestHTTP

    BestHTTP

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

    No, it will send it as multipart/form-data.
    If you have to send json, you have to create a string, convert it to a byte[] and send it with the plugin. Something like this:
    Code (CSharp):
    1. Uri uri = new Uri("http://httpbin.org/post");
    2.  
    3. HTTPRequest request = new HTTPRequest(uri, HTTPMethods.Post, (req, resp) =>
    4. {
    5.     switch (req.State)
    6.     {
    7.         // The request finished without any problem.
    8.         case HTTPRequestStates.Finished:
    9.             if (resp.IsSuccess)
    10.             {
    11.                 Debug.Log("Request Finished Successfully! Response: " + resp.DataAsText);
    12.  
    13.             }
    14.             else // Internal server error?
    15.                 Debug.LogWarning(string.Format("Request Finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
    16.                                                 resp.StatusCode,
    17.                                                 resp.Message,
    18.                                                 resp.DataAsText));
    19.             break;
    20.  
    21.         // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
    22.         case HTTPRequestStates.Error:
    23.             Debug.LogWarning("Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
    24.             break;
    25.  
    26.         // The request aborted, initiated by the user.
    27.         case HTTPRequestStates.Aborted:
    28.             Debug.LogWarning("Request Aborted!");
    29.             break;
    30.  
    31.         // Ceonnecting to the server is timed out.
    32.         case HTTPRequestStates.ConnectionTimedOut:
    33.             Debug.LogError("Connection Timed Out!");
    34.             break;
    35.  
    36.         // The request didn't finished in the given time.
    37.         case HTTPRequestStates.TimedOut:
    38.             Debug.LogError("Processing the request Timed Out!");
    39.             break;
    40.     }
    41. });
    42.  
    43. var obj = new
    44. {
    45.     name = "Phil",
    46.     type = "human",
    47.     data = tex.EncodeToPNG()
    48. };
    49.  
    50. string json = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
    51.  
    52. request.SetHeader("Content-Type", "application/json");
    53. request.RawData = System.Text.Encoding.UTF8.GetBytes(json);
    54.  
    55. request.Send();
    I used Newtonsoft's json encoder here, 'data' will be a byte array, and the json encoder will encode it as Base64:
    Code (JavaScript):
    1. {
    2.     "name": "Phil",
    3.     "type": "human",
    4.     "data": "iVBORw0KGgoAAAANSUhEUgAABAAAAAIACAIAAACTr4nuAAAgAElEQVR4Aey9aa9tSXIddqc31dBV9bqqeiKbVotsmgJBQDBMWJBFwoYAwpAhQ7CgXyDwtxn+bMgfDcswRZAfRAmWpVaTZnNqsqvZVdVvfnf0WrEyIyOHvc/e5547vXr73bdPZGTEisjIyNy5h7PP/t7ewZ62fRD7JC8u9vaNyBXpc+oD8tgqFTEEYrWtbsC/yA5EmX1oJcWLi/NUI0N7h/v7R1H2FtIXydUNru13QTOF3N5KGxELQauqYqHEzeQrlegVTF94pdyQz9hbkT3AXLhwJyMdTW5NFwcEAdPy4eCgSid3TGIxaKpyvlc1Ko2LLtbwvRhhnSki6kbaxaQ"
    5. }
     
  35. fafase

    fafase

    Joined:
    Jul 3, 2012
    Posts:
    156
    Ok, this is what I was doing but then I get Payload too large error. I am trying to send an image within a json file.
    It does work fine with small images but now it seems to fail with large one.

    I guess it requires the multipart/form-data you mention instead of simple json file.
     
  36. BestHTTP

    BestHTTP

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

    I don't think you should switch for a form if the server expects json data.
    You should check your server's setup if you are receiving a 413 - Payload too large error:
     
  37. spanagiotis

    spanagiotis

    Joined:
    Feb 5, 2013
    Posts:
    5
    @BestHTTP

    Hey,
    Just bought the asset and it's pretty easy to use, however, I'm encountering an issue with .netcore 2.0 and signalr.

    I've been getting the following error message:
    Negotiation request failed with error: Negotiation request finished Successfully, but the server sent an error. Status Code: 404-Not Found Message: Uri: http://localhost:64059/negotiate?tid=0&_=883701414&clientProtocol=1.5&connectionData=[{"Name":"/GameHub"}]

    After doing some research I found a stack overflow answer that mentions this:
    https://stackoverflow.com/questions...-0-0-alpha2-27025-signalr-negotiate-404-error
    SignalR for ASP.NET Core does not use the /negotiate endpoint anymore. The new SignalR server is not compatible with old client and the new clients are not compatible with the old SignalR server.

    Are there any plans to get the besthttp.signalr functions to work with the most recent version of .netcore signalr?

    Thanks!
     
  38. sumitx

    sumitx

    Joined:
    Mar 16, 2017
    Posts:
    2
    Thank you very much!
     
  39. BestHTTP

    BestHTTP

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

    SignalR Core is still in its preview phase and the protocol is still changing. I have a version that seems to work with the preview version. Sent a download link and instructions for the package in a private message.
     
  40. MoranGlobo

    MoranGlobo

    Joined:
    Dec 18, 2016
    Posts:
    3
    Hi! I'm having what looks like a DNS-resolving issue on certain IOS devices.

    Unity 2017.3.1p4, built for iOS and running on iPhone 6s with latest OS version.
    BestHTTP Pro version 1.10.3

    When trying to connect to a hostname,
    Dns.BeginGetHostAddresses
    returns successfully but
    Dns.EndGetHostAddresses
    always returns a null object.

    This only happens when I'm connected via 4G, does not reproduce on WiFi.

    Please advise... Thanks!
     
  41. BestHTTP

    BestHTTP

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

    I couldn't reproduce it, but you can try out setting the HTTPManager.ConnectTimeout to TimeSpan.Zero, then instead of Begin/EndGetHostAddresses it will use the blocking Dns.GetHostAddresses:
    Code (CSharp):
    1. BestHTTP.HTTPManager.ConnectTimeout = TimeSpan.Zero;
     
  42. TailKitty

    TailKitty

    Joined:
    Nov 23, 2016
    Posts:
    6
    Hi, with Unity 2017.3.1p4 and previous patches also i had a problem with the BestHttp plugin reference in C# project.
    For some reason it wont appear in C# project with visual Studio 2017;

    I can include it manually via resolving the issue and it will be added into the C# project and even could be build normally But in Unity Editor it still shown that these refs are missing and it doesn't see that the build was successful;

    Any idea about this behaviour? I'm currently using BestHttp basic with the fix you sent me via email for solving some other deploying issues;
     
  43. TailKitty

    TailKitty

    Joined:
    Nov 23, 2016
    Posts:
    6
    Lol..Can't ask this question in Unity community because of strange session problem there. Every time it is asking me to log in before asking question and never remembers my account data. Chrome, Edge - same result Love it.
     
  44. BestHTTP

    BestHTTP

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

    I had an email conversation about a similar issue. Unfortunately i can't find the conversation itself so i don't know more detail, but what i know is that when the client imported the plugin and another one (Sirenx's Odin inspector) from the asset store, the generated visual studio project reported the BestHTTP namespace as a unknown one.
    We found no solution, and I couldn't reproduce it locally either.
     
  45. fafase

    fafase

    Joined:
    Jul 3, 2012
    Posts:
    156
    Hi,
    I am running a method to check if device is connected to internet. Basically polling if I can reach Google.com as such:

    Code (CSharp):
    1.  
    2.     private void CheckForConnection()
    3.     {
    4.         this.request = HttpRequest.SendRequest("https://www.google.com/", (req, res) =>
    5.         {
    6.             if (res.IsSuccess == false)
    7.             {
    8.                 Invoke("CheckForConnection", 5.0f);
    9.                 DisplayNoConnection();
    10.                 };
    11.             }
    12.         });
    13.    }
    I was thinking that if the request is not successful then it means I could not connect. But instead, the response object is null and obviously throws an error.

    I can of course check if(res == null) but shouldn't it return no success since the status code is 503?

    Cheers
     
  46. BestHTTP

    BestHTTP

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

    When the internet isn't reachable the plugin can't download a response, so it will be null!
    Status code 503 is "Service unavailable", and it can be sent back from the remote server. The plugin can't and will not create a 'fake' response object with a made up status code.
     
  47. Writeline

    Writeline

    Joined:
    Dec 17, 2013
    Posts:
    1
    Is this still an issue? Downloaded yesterday from the store and retrieving this here

    UnityException: Failed to run serialization weaver with command "Temp\StagingArea\Data\Managed\BestHTTP.dll" "-pdb" "-verbose" "-unity-engine=Temp\StagingArea\Data\Managed\UnityEngine.CoreModule.dll" "Temp\StagingArea\TempSerializationWeaver" "-lock=UWP\project.lock.json" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Facade" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Calls.CallsVoipContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.SocialInfo.SocialInfoContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.StartupTaskContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.Custom.CustomDeviceContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.DevicesLowLevelContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.Printers.PrintersContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.SmartCards.SmartCardBackgroundTriggerContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.SmartCards.SmartCardEmulatorContract\5.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Foundation.FoundationContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Foundation.UniversalApiContract\5.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Gaming.XboxLive.StorageApiContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Graphics.Printing3D.Printing3DContract\4.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Networking.Connectivity.WwanContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Services.Store.StoreContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Services.TargetedContent.TargetedContentContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.System.Profile.ProfileHardwareTokenContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.System.Profile.ProfileSharedModeContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.UI.ViewManagement.ViewManagementViewScalingContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Activation.ActivatedEventsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Activation.ActivationCameraSettingsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Activation.ContactActivatedEventsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Activation.WebUISearchActivatedEventsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Background.BackgroundAlarmApplicationContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Calls.Background.CallsBackgroundContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Calls.LockScreenCallContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.FullTrustAppContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Preview.InkWorkspace.PreviewInkWorkspaceContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Preview.Notes.PreviewNotesContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Resources.Management.ResourceIndexerContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Search.Core.SearchCoreContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Search.SearchContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Wallet.WalletContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.Portable.PortableDeviceContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.Printers.Extensions.ExtensionsContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.Scanners.ScannerDeviceContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Devices.Sms.LegacySmsApiContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Gaming.Input.GamingInputPreviewContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Gaming.Preview.GamesEnumerationContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Gaming.UI.GameChatOverlayContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Gaming.UI.GamingUIProviderContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Globalization.GlobalizationJapanesePhoneticAnalyzerContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Management.Deployment.Preview.DeploymentPreviewContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Management.Workplace.WorkplaceSettingsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.AppBroadcasting.AppBroadcastingContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.AppRecording.AppRecordingContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.Capture.AppBroadcastContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.Capture.AppCaptureContract\4.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.Capture.AppCaptureMetadataContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.Capture.CameraCaptureUIContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.Capture.GameBarContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.Devices.CallControlContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.MediaControlContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.Playlists.PlaylistsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Media.Protection.ProtectionRenewalContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Networking.NetworkOperators.LegacyNetworkOperatorsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Networking.Sockets.ControlChannelTriggerContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Networking.XboxLive.XboxLiveSecureSocketsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Perception.Automation.Core.PerceptionAutomationCoreContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Security.EnterpriseData.EnterpriseDataContract\5.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Security.ExchangeActiveSyncProvisioning.EasContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Services.Maps.GuidanceContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Services.Maps.LocalSearchContract\4.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Storage.Provider.CloudFilesContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.System.Profile.SystemManufacturers.SystemManufacturersContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.System.Profile.ProfileRetailInfoContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.System.UserProfile.UserProfileContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.System.UserProfile.UserProfileLockScreenContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.UI.ApplicationSettings.ApplicationsSettingsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.UI.Core.AnimationMetrics.AnimationMetricsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.UI.Core.CoreWindowDialogsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.UI.Xaml.Hosting.HostingContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Web.Http.Diagnostics.HttpDiagnosticsContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.System.SystemManagementContract\4.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.Calls.CallsPhoneContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.ApplicationModel.CommunicationBlocking.CommunicationBlockingContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Embedded.DeviceLockdown.DeviceLockdownContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Networking.NetworkOperators.NetworkOperatorsFdnContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Phone.PhoneContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Phone.StartScreen.DualSimTileContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.UI.WebUI.Core.WebUICommandBarContract\1.0.0.0" "-additionalAssemblyPath=Temp\StagingArea\Data\Managed".
    Symbols will be read from Temp\StagingArea\Data\Managed\UnityEngine.CoreModule.pdb
    Symbols will be read from Temp\StagingArea\Data\Managed\BestHTTP.pdb
    Weaving assembly C:\src\FinPrep\Temp\StagingArea\Data\Managed\BestHTTP.dll
    System.InvalidOperationException: Operation is not valid due to the current state of the object.
    at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader)
    at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
    at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
    at usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngineAssemblyDefinition, ReaderParameters readerParameters) in C:\buildslave\unity\build\Tools\SerializationWeaver\sw\Weaver.cs:line 95
    at usw.Weaver.Weave() in C:\buildslave\unity\build\Tools\SerializationWeaver\sw\Weaver.cs:line 50
    at usw.Program.RunProgram(ConversionOptions options) in C:\buildslave\unity\build\Tools\SerializationWeaver\sw\Program.cs:line 33
    at usw.Program.Main(String[] args) in C:\buildslave\unity\build\Tools\SerializationWeaver\sw\Program.cs:line 14
    PostProcessWinRT.RunSerializationWeaver () (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:810)
    PostProcessWinRT.Process () (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:203)
    UnityEditor.WSA.BuildPostprocessor.DoPostProcess (BuildPostProcessArgs args) (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/ExtensionModule.cs:117)
    UnityEditor.WSA.BuildPostprocessor.PostProcess (BuildPostProcessArgs args) (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/ExtensionModule.cs:124)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Am I missing something?
     
  48. dev_runeofdark

    dev_runeofdark

    Joined:
    Oct 27, 2016
    Posts:
    10
    Hi,

    I have a connection problem to my socket server at heroku. at heroku I can see that besthttp makes a connection to heroku and heroku accept that, but than besthttp closed the connection directly without response. And I got no errors in Unity.

    Code (CSharp):
    1. using BestHTTP.SocketIO;
    2. using BestHTTP;
    3. using System;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6. using UnityEngine;
    7. using BestHTTP.WebSocket;
    8.  
    9. public class SocketIoManager : MonoBehaviour {
    10.  
    11.     protected SocketManager manager;
    12.  
    13.     [SerializeField]
    14.     protected string url;
    15.  
    16.     // Use this for initialization
    17.      void Start () {
    18.         SocketOptions options = new SocketOptions()
    19.         {
    20.             AutoConnect = false,
    21.             ConnectWith = BestHTTP.SocketIO.Transports.TransportTypes.WebSocket,
    22.             Timeout = new TimeSpan(0, 0, 0, 0, 50000)
    23.         };
    24.  
    25.         manager = new SocketManager(new Uri("ws://cgi-socket-test.herokuapp.com/"), options);
    26.  
    27.         manager.Socket.On(SocketIOEventTypes.Connect, OnConnect);
    28.         manager.Socket.On(SocketIOEventTypes.Disconnect, OnDisconnect);
    29.         manager.Socket.On(SocketIOEventTypes.Error, OnError);
    30.         manager.Socket.On("connecting", OnConnecting);
    31.         manager.Socket.On("reconnecting", OnReconnnecting);
    32.         manager.Socket.On("connect_timeout", OnConnectError);
    33.  
    34.          manager.Open();
    35.      }
    36.  
    37.     private void OnConnectError(Socket socket, Packet packet, object[] args)
    38.     {
    39.         Debug.Log("connection error");
    40.     }
    41.  
    42.     private void OnReconnnecting(Socket socket, Packet packet, object[] args)
    43.     {
    44.         Debug.Log("reconnecting");
    45.     }
    46.  
    47.     private void OnConnecting(Socket socket, Packet packet, object[] args)
    48.     {
    49.         Debug.Log("connecting");
    50.     }
    51.  
    52.     private void OnError(Socket socket, Packet packet, object[] args)
    53.      {
    54.          Debug.Log("error");
    55.      }
    56.  
    57.      private void OnDisconnect(Socket socket, Packet packet, object[] args)
    58.      {
    59.          Debug.Log("disconnect");
    60.      }
    61.  
    62.      private void OnConnect(Socket socket, Packet packet, object[] args)
    63.      {
    64.          Debug.Log("connect");
    65.      }
    66. }
    67.  
    Heroku logs.PNG

    I thought it was the timeout and increase that but that isn't the problem.

    I am using unity2017.3 and the besthttp basic package.
     
  49. BestHTTP

    BestHTTP

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

    BestHTTP

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

    What scripting backend are you using? The experimental has some bugs.

    You can also set the plugin's logger to a verbose mode:
    Code (CSharp):
    1. BestHTTP.HTTPManager.Logger.Level = BestHTTP.Logger.Loglevels.All;
    Sending the produced log may help us catch what went wrong.

    I tried out your code too, but connecting to the server but it returns with 503 - Service Unavailable: