Search Unity

Best HTTP Released

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

  1. adamt

    adamt

    Joined:
    Apr 1, 2014
    Posts:
    116
    True, in my experience the connection did resume once my game came back from being suspended (without forcing a soft-close), but the fact that Best HTTP logs an error when it does that won't work for me: our logging system would fill up with these ignorable messages, and it also seems a bit like using exceptions for flow control. I can remove the log statement from your code, but I'd rather not for maintainability purposes.
     
  2. BestHTTP

    BestHTTP

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

    You can also set the logging level of the plugin:
    Code (CSharp):
    1. HTTPManager.Logger.Level = BestHTTP.Logger.Loglevels.Exception;
    Setting to Exception the plugin will log only the really unexpected problems, or errors came from 'user' code (callbacks, manly). The default log level for debug builds is Warning, in release builds it's Error.

    I try to avoid flow control with exceptions (and more rarely the goto statement outside of switches) but there are times when it helps to keep the code more readable and maintainable. As I remember I used it in the HTTPConnection class only. In higher levels I use c# delegates/events for callbacks, or keeping references to objects and call straight the function. For example the Socket.IO transports will keep a reference to the manager class and will call its OnTransportError when an unexpected error occurs, like in your example.

    I use an interface and implement it explicitly to hide functions that shouldn't called from outside of the plugin. Marking these functions with internal would only help if I would distribute the plugin in dll forms only. Ofc, you can still cast it to this interface, as in my example, but it's not as straightforward as regular internal functions.
     
    Last edited: Jan 14, 2016
  3. adamt

    adamt

    Joined:
    Apr 1, 2014
    Posts:
    116
    Sounds great. I'll change the log level if things get too chatty in development. Thanks for your quick responses, as usual!
     
  4. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @BestHTTP
    So using that code you shared, I'm getting a "Connection Timed Out!" error. Does that for sure mean that its a issue with my server?
     
  5. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @adamt Forgot to mention, that you can also write a custom logger implementing the ILogger interface from the BestHTTP.Logger namespace, and you can set an instance to the HTTPManager.Logger property.
    In some cases it can be handy.
     
  6. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @rxmarccall It can be, but not exclusively.
    You can try to increase the ConnectTimeout property to widen the threshold (the default is 20 sec):
    Code (CSharp):
    1. HTTPManager.ConnectTimeout = TimeSpan.FromSeconds(60);
     
  7. NK-Dmitry

    NK-Dmitry

    Joined:
    Nov 10, 2015
    Posts:
    7
    Hi,

    When using socket.io middleware on the namespace which returns an error, bestHTTPpro breaks due to a null reference.

    E.g:

    // on the server
    namespace.use(function (socket, next) {
    if ("reject socket connection for whatever reason") {
    next(new Error("some_error_message"));​
    }​
    });​

    JSON.Json.Decode method is assuming that packet.Payload is a json object, however, when you interrupt namespace middleware stack with an error and I quote socketio documentation: "Errors passed to middleware callbacks are sent as special error packets to clients.". Which end up being contents of the message property plucked out of the node error object. This would normally be just a string.

    As a result, Json.Decode returns a NULL!

    When I set error message to null, error listeners ends up not being invoked.

    // this is not invoked
    socket.On(SocketIOEventTypes.Error, (Socket s, Packet p, object[] args) =>​
    {
    UnityEngine.Debug.Log("ERRORRRR");
    });

    And when It is set to a message string like it should be, best http breaks attempting to access a property of a null object with the following stack trace.

    Error Ex [WebSocketTransport]: OnMessage - Message: Object reference not set to an instance of an object StackTrace: at BestHTTP.SocketIO.Socket.BestHTTP.SocketIO.ISocket.OnPacket (BestHTTP.SocketIO.Packet packet) [0x00076] in [edited project path]\Assets\Modules\Best HTTP (Pro)\BestHTTP\SocketIO\Socket.cs:384
    at BestHTTP.SocketIO.SocketManager.BestHTTP.SocketIO.IManager.OnPacket (BestHTTP.SocketIO.Packet packet) [0x0006f] in [edited project path]\Assets\Modules\Best HTTP (Pro)\BestHTTP\SocketIO\SocketManager.cs:536
    at BestHTTP.SocketIO.Transports.WebSocketTransport.OnPacket (BestHTTP.SocketIO.Packet packet) [0x00095] in [edited project path]\Assets\Modules\Best HTTP (Pro)\BestHTTP\SocketIO\Transports\WebSocketTransport.cs:334
    at BestHTTP.SocketIO.Transports.WebSocketTransport.OnMessage (BestHTTP.WebSocket.WebSocket ws, System.String message) [0x00049] in [edited project path]\Assets\Modules\Best HTTP (Pro)\BestHTTP\SocketIO\Transports\WebSocketTransport.cs:117 Solution 'nk-chat-unity' ‎(1 project) Assets/Modules/Best HTTP (Pro)/BestHTTP/Logger/DefaultLogger.cs 89 ​

    A fix for this would be much appreciated :)
    Please let me know if you need more info on this one.

    Thanks
     
  8. Jcsnider

    Jcsnider

    Joined:
    Jul 16, 2013
    Posts:
    3
    Hi there,

    I just bought this plugin and I am witnessing some weird behavior I am hoping you can shed some light on.

    I am only using the basic HTTP Get/Post functionality. I am sending a large request ~30mb, but whenever I debug my app in XCode the Network panel slowly shows ~60mb of data being sent. Here is the structure of my code:
    http://pastebin.com/2eQZngTE

    Any reason why XCode shows 60mb of data being sent and taking 2x as long to complete the request?

    Thanks,
    JC
     
  9. BestHTTP

    BestHTTP

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

    You are using Credentials, and the plugin doesn't know what type authentication the server expects, so it can't send the authorization header with the first request. It must do a challange-response turn, to find out what and how it should send it.
    If you know what type it expects, you can set it to the Credentials' constructor:
    Code (CSharp):
    1. myRequest.Credentials = new Credentials(AuthenticationTypes.Basic, user, pass);
    If it should be Digest, then the plugin still have to send the request without the header, to get back some data that have to be used in the header construction. In this case you can get better result, if you first send out a dummy request to the server to get back these. The plugin will reuse the received data for all consecutive requests.
     
    Last edited: Jan 19, 2016
  10. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @NK-Dmitry Thanks for your report, I will take a look asap.
     
  11. Jcsnider

    Jcsnider

    Joined:
    Jul 16, 2013
    Posts:
    3
    Thank you sir! Well worth the $40!
     
    BestHTTP likes this.
  12. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @NK-Dmitry Sent you a link to an updated package.
     
  13. NK-Dmitry

    NK-Dmitry

    Joined:
    Nov 10, 2015
    Posts:
    7
    Thank you for getting on top of it so fast, will test it out today at work.

    EDIT:
    @BestHTTP: I can confirm that it is now resolved, thank you.
     
    Last edited: Jan 19, 2016
  14. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @NK-Dmitry Great! It will be included in the next update too, you will be update the package as usually.
     
  15. Nyxz

    Nyxz

    Joined:
    Mar 16, 2015
    Posts:
    3
    @BestHTTP
    I've just update to Unity 5.3.1. Then i get "StackOverflowException" when i use HttpRequest. Don't have any more information, just this exception. I've tried disable this function and the exception gone.
    does the Coroutine has problem?

    Thank you.
     
  16. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Nyxz There were changes recently how Unity handles coroutins, and how it should be done now. Are you using the latest version of the plugin too?
    Anyway, just downloading Unity 5.3.1 and will check it out.
     
  17. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Nyxz Wasn't able to reproduce it. If you didn't already, please use the latest version of the plugin for Unity 5.3.x.
     
  18. Nyxz

    Nyxz

    Joined:
    Mar 16, 2015
    Posts:
    3
    @BestHTTP : oh,i using ver 1.9.4 with Unity 5.1.4, then update to 5.3.1 :)
     
  19. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Nyxz Improved compatibility was added in v1.9.7, you should update. :)
     
  20. Nyxz

    Nyxz

    Joined:
    Mar 16, 2015
    Posts:
    3
  21. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @Nyxz Just a little addition. With Unity 5.3.x you can yield return straight on the request, you don't have to call StartCoroutine on it:
    Code (CSharp):
    1. yield return request;
    It's a little thing, but it's much leaner, nicer.
     
  22. KristianE

    KristianE

    Joined:
    Nov 16, 2012
    Posts:
    4
    Hi I am having some trouble with the latest version of Unity (5.3.1) and the latest version of BestHTTP (1.9.8) when making WebGL builds and using POST. For some reason I am not able to add any POST fields in WebGL but it works fine in the editor.

    If I use a script like:
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using System.Collections;
    4. using BestHTTP;
    5.  
    6. public class TestScript : MonoBehaviour {
    7.  
    8.     void Start () {
    9.         HTTPRequest request = new HTTPRequest(new Uri("http://workspace/api/game"), HTTPMethods.Post, OnLoginRequestFinished);
    10.         request.AddField("username", "SomeUser");
    11.         request.AddField("password", "SomePass");
    12.         request.Send();
    13.     }
    14.  
    15.     void OnLoginRequestFinished(HTTPRequest request, HTTPResponse response) {
    16.        Debug.Log(response.DataAsText);
    17.     }
    18. }
    19.  
    and a php test script like:
    Code (PHP):
    1. <?php
    2. header("Content-Type: application/json");
    3. echo var_dump($_POST);
    4. ?>
    then when running in the Editor I will get:
    but when running my WebGL build I will get:
    so none of my post headers are actually being added in the request... Is there something that I am doing wrong in order to achieve this result or is it a regression?
     
  23. BestHTTP

    BestHTTP

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

    Just tried out with Unity 5.3.1.
    My code was this:
    Code (CSharp):
    1. void WebGLPOSTTest()
    2. {
    3.     Uri uri = new Uri("http://httpbin.org/post");
    4.  
    5.     HTTPRequest request = new HTTPRequest(uri, HTTPMethods.Post, OnRequestFinished);
    6.  
    7.     request.AddField("username", "SomeUser");
    8.     request.AddField("password", "SomePass");
    9.  
    10.     request.Send();
    11. }
    12.  
    13. void OnRequestFinished(HTTPRequest req, HTTPResponse resp)
    14. {
    15.     switch (req.State)
    16.     {
    17.         // The request finished without any problem.
    18.         case HTTPRequestStates.Finished:
    19.             if (resp.IsSuccess)
    20.             {
    21.                 Debug.Log("Request Finished Successfully! Data : " + resp.DataAsText);
    22.             }
    23.             else // Internal server error?
    24.                 Debug.LogWarning(string.Format("Request Finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
    25.                                                 resp.StatusCode,
    26.                                                 resp.Message,
    27.                                                 resp.DataAsText));
    28.             break;
    29.  
    30.         // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
    31.         case HTTPRequestStates.Error:
    32.             Debug.LogWarning("Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
    33.             break;
    34.  
    35.         // The request aborted, initiated by the user.
    36.         case HTTPRequestStates.Aborted:
    37.             Debug.LogWarning("Request Aborted!");
    38.             break;
    39.  
    40.         // Ceonnecting to the server is timed out.
    41.         case HTTPRequestStates.ConnectionTimedOut:
    42.             Debug.LogError("Connection Timed Out!");
    43.             break;
    44.  
    45.         // The request didn't finished in the given time.
    46.         case HTTPRequestStates.TimedOut:
    47.             Debug.LogError("Processing the request Timed Out!");
    48.             break;
    49.     }
    50. }
    I received back all of the form paramaters as expected. You can inspect your browser's console for additional logs, and also you can also check what requests and responses are made with an intermediate proxy (like http://www.charlesproxy.com/).
     
  24. KristianE

    KristianE

    Joined:
    Nov 16, 2012
    Posts:
    4
    Thank you so much for that very fast reply!

    You are absolutely correct. The problem was not with BestHTTP but with my nginx server loosing the POST vars. I think that might have something to do with a redirection problem perhaps. Anyhow. I found that calling the URL "http://workspace/api/game/index.php" instead of "http://workspace/api/game" fixes my problem in WebGL, and the editor works with both URL's.

    Thanks again for your swift response.
     
    DeltaCygniLabs likes this.
  25. Cheshire Cat

    Cheshire Cat

    Joined:
    Sep 18, 2012
    Posts:
    39
    Hey, I've been using your plugin for a while, great job so far.
    No I want to send a binary chunk using multipart HTTP request, aka "curl.exe -F "image=@$FILE_NAME" $SERVER_URL".

    Assuming I've got that chunk in byte[], how would it be possible to send it with your plugin?

    10x
     
  26. BestHTTP

    BestHTTP

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

    The -F switch will send it as a multipart form data. So, it would be something like this:
    Code (CSharp):
    1. var request = new HTTPRequest(new Uri("http://httpbin.org/post"), HTTPMethods.Post, (req, resp) =>
    2.     {
    3.         switch (req.State)
    4.         {
    5.             // The request finished without any problem.
    6.             case HTTPRequestStates.Finished:
    7.                 if (resp.IsSuccess)
    8.                 {
    9.                     // Log out the identifier of the request, and the response from the server.
    10.                     Debug.Log("Request Finished Successfully! Text: " + resp.DataAsText);
    11.                 }
    12.                 else
    13.                     Debug.LogWarning(string.Format("Request Finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
    14.                                                     resp.StatusCode,
    15.                                                     resp.Message,
    16.                                                     resp.DataAsText));
    17.                 break;
    18.  
    19.             // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
    20.             case HTTPRequestStates.Error:
    21.                 Debug.LogWarning("Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
    22.                 break;
    23.  
    24.             // The request aborted, initiated by the user.
    25.             case HTTPRequestStates.Aborted:
    26.                 Debug.LogWarning("Request Aborted!");
    27.                 break;
    28.  
    29.             // Ceonnecting to the server is timed out.
    30.             case HTTPRequestStates.ConnectionTimedOut:
    31.                 Debug.LogError("Connection Timed Out!");
    32.                 break;
    33.  
    34.             // The request didn't finished in the given time.
    35.             case HTTPRequestStates.TimedOut:
    36.                 Debug.LogError("Processing the request Timed Out!");
    37.                 break;
    38.         }
    39.     });
    40.  
    41. byte[] binary = tex.EncodeToPNG();
    42. request.AddBinaryData("image", binary, "image.png", "image/png");
    43.  
    44. request.FormUsage = BestHTTP.Forms.HTTPFormUsage.Multipart;
    45.  
    46. request.Send();
    Setting the FormUsage wouldn't be necessary (the plugin will use it anyway for binary data), but, it will make sure to enforce the -F behavior.
     
  27. Cheshire Cat

    Cheshire Cat

    Joined:
    Sep 18, 2012
    Posts:
    39
    Worked perfectly, thanks
     
  28. Tunkali

    Tunkali

    Joined:
    Feb 5, 2013
    Posts:
    54
    Hi,

    I want to use websockets for browser<-->game communication over a nodejs server. I can receive perfectly messages from the server but unfortunately my server doesn't understand the unity client. So my messages are coming as object Object. I guess it has something to do with stringformat/utf8/binarystuff. Is it possible to send messages with utf 8 or do I need to configure my server/unityclient for reading/sending bytestream?

    Because I would like to establish a JSON communication between all parties. Maybe you could show me the right direction or show me a small basic example?

    Thank you!
     
  29. mobile.earth

    mobile.earth

    Joined:
    Feb 20, 2015
    Posts:
    1
    Hi BestHttp Creator,
    Our company uses BestHttp for Android and iOS and it works fine! But when we switch to Windows Desktop platform, we get this crash error whenever we make a POST call. The same POST call works fine in Android and iOS platforms. Please help!!! This is an urgent bug we need to fix ASAP in order to support desktop platforms.

    Ex [HTTPRequest]: SendOutTo - Message: Object reference not set to an instance of an object  StackTrace:   at BestHTTP.Extensions.Extensions.GetASCIIBytes (System.String str) [0x00000] in <filename unknown>:0

      at BestHTTP.HTTPRequest+<SendHeaders>c__AnonStorey15.<>m__2E (System.String header, System.Collections.Generic.List`1 values) [0x00000] in <filename unknown>:0

      at BestHTTP.HTTPRequest.EnumerateHeaders (BestHTTP.OnHeaderEnumerationDelegate callback) [0x00000] in <filename unknown>:0

      at BestHTTP.HTTPRequest.SendHeaders (System.IO.BinaryWriter stream) [0x00000] in <filename unknown>:0

      at BestHTTP.HTTPRequest.SendOutTo (System.IO.Stream stream) [0x00000] in <filename unknown>:0
     
  30. BestHTTP

    BestHTTP

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

    First of all, you should use the latest version of the plugin if you didn't already.
    You have two ways to send messages to the server: you can send textual and binary data. If you want to send (json) strings you should send it straight, without converting it to a byte[]!
     
  31. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @mobile.earth

    It looks like that there is a null value for a header or for a header name. Are setting any custom header?
    I will send a link to an updated package in private. It will not throw an exception for this case, and will log out a warning if it can.
     
  32. Tunkali

    Tunkali

    Joined:
    Feb 5, 2013
    Posts:
    54
    @BestHTTP: It seems, that the problem was my servercode which was build on a http connection from the example. Now I use a much simpler servercode and it works without problems. My only problem is to adress specific users via json. But thats no concern of your plugin ;-)
     
  33. NK-Dmitry

    NK-Dmitry

    Joined:
    Nov 10, 2015
    Posts:
    7
    Hi,

    I have not found a way to update AdditionalQueryParams for socketio connection manager without hacking out line of code which returns a cached 'BuiltQueryParams' member inside 'BestHTTP.SocketIO.SocketOptions' class.

    Would that be possible to have a way to invalidate BuiltQueryParams on demand in cases when we need to modify query before reconnection attempt?

    Is there already a way to achieve this, which I am missing?

    Thank you
     
  34. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @NK-Dmitry

    You are right, and it's reasonable to add one.

    A function to null out the cached value looks good, but something like an ObservableDictionary would be better to be able to call back when it's changed.
    However it would add more code to the plugin.
     
  35. NK-Dmitry

    NK-Dmitry

    Joined:
    Nov 10, 2015
    Posts:
    7
    @BestHTTP

    I imagine it will only be an insignificant amount of code compared to the entire client project, and a necessary evil in this case.

    Otherwise, to achieve similar results, we would need to implement yet another socket.io event which arguably would be even more code and complications on the side of BestHTTP user code.

    ObservableCollection looks like a good fit, I don't even mind sending a candidate change to you since I am digging into the BestHttp code here anyway :)

    Thanks
     
  36. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    @NK-Dimitry I will go with the ObservableDictionary, it's more user-friendly and i think i will be able to use it at other places too (the SignalR implementation has a similar approach).
     
    Last edited: Feb 16, 2016
  37. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I'm looking for asset to deal with my REST server(nodejs+json), what's the difference between basic and pro version?
     
  38. BestHTTP

    BestHTTP

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

    The Pro version:
    • Features can be disabled to lower build size
    • You can access internal functions for advanced use-cases
    • You will receive all the source
    • I can send patches and/or improvements much quicker
    • Support for older Unity version (4.x)
    • Can support more platforms

    Feature wise they are almost completely identical (see first point above).
     
    zhuchun likes this.
  39. zerong_MT

    zerong_MT

    Joined:
    Feb 18, 2016
    Posts:
    1
    i fixed my the stupid question,
    thanks:)
     
    Last edited: Feb 18, 2016
  40. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
  41. BestHTTP

    BestHTTP

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

    It can be used to download it, but it doesn't have a direct function or property to return an AssetBundle instance.
    The plugin itself can't version it or check the crc of the content neither. But it will check the server for fresh data.

    There is an example to download and use an AssetBundle in the package.
     
  42. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
    Thanks.
     
  43. raybarrera

    raybarrera

    Joined:
    Nov 20, 2010
    Posts:
    207
    @BestHTTP I seem to be encountering an odd error. I'm trying to access a web service via HTTP. At first, the parameters were being sent in the request body. This would return a 404 no matter what, after some investigation, we thought maybe this wasn't supported, so we changed the back end to use a parameterized URI instead. No dice 404.

    In the browser, the request body approach returns an error as expected (no parameters set by just hitting the uri), and the parameterized approach works as expected.

    Any idea why I might be getting the 404 only in Unity via the plugin?
     
  44. BestHTTP

    BestHTTP

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

    Can you send a sample url that doesn't work?
     
  45. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,664
    Latest version of the plugin is out in the Asset Store!

    Most notable change is the added Per-Message Deflate Compression extension support for the WebSocket implementation. With this addition other protocols (Socket.IO and SignalR) can leverage from this new feture too.

    Changelog of this update:

    1.9.9 (2016.02.16)
    • General
      • [Bugfix] On redirection the plugin tried to load from the cache for the wrong uri
      • [Bugfix] HTTPUpdateDelegator will now shut down the update thread if it’s used on application exit
      • [Bugfix] Cookies will be sent for protocols other than http too
      • [Bugfix] Empty headers will no longer sent out
      • [Bugfix] Null values in headers will no longer cause an exception
      • [Improvement] Added some missing documentation.
      • [Improvement] Exception logging now will include inner exceptions too

    • WebSockets
      • [New Feature] Support for extensions added
      • [New Feature] Per-Message Deflate Compression extension added

    • Socket.IO
      • [Improvement] Custom errors by middlewares are now supported
      • [Improvement] Socket.Options’ AdditionalQueryParams changed from Dictionary to ObservableDictionary to automatically delete the cached value when it’s changed
      • [Bugfix] The plugin will not decode the payload for Emit callbacks

    • SignalR
      • [Improvement] AdditionalQueryParams changed from Dictionary to ObservableDictionary to automatically delete the cached value when it’s changed
     
  46. xpxilom

    xpxilom

    Joined:
    Aug 28, 2014
    Posts:
    30
    not charge the full answer

    @BestHTTP

    Code (CSharp):
    1. string GetGroups =  "https://api.facebook.com/restserver.php?access_token="+ access_token + "&locale=en_US&method=bookmarks.get&api_key=" + apiKey +"&format=JSON&v=1.0";
    2.  
    3.                 HTTPRequest request2 = new HTTPRequest(new Uri(GetGroups), HTTPMethods.Get, (req, resp) =>
    4.                 {
    5. Debug.Log(resp.DataAsText.Length);
    6. }
    7.  
    8.  
    9.             request2.Send();
    10.  
    11.  

    When I print off the result, I never get the whole JSON phrase, only a shortened version with the print message ending in:

    Any idea why this is happening? Is it just the Print method that is doing this?

    It should load all the groups of my Facebook
    But it only loads a small part
     
    Last edited: Feb 23, 2016
  47. BestHTTP

    BestHTTP

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

    The plugin doesn't try to truncate or to do any other transformation. I think it should be Unity's console that doesn't want to display the whole text.
     
  48. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
    @BestHTTP
    Hey buddy!

    I am trying some texture downloads. We are working with https only.

    I seem to be having authentication issues with amazon CDN.

    If I try to download a file from one domain, e.g.:
    https://for4blahsOr6woos.cloudfront.net/woo/weepee.png - the download succeeds.

    If I try to reach the same file but with a different domain, which works with WWW texture downloads, it fails with an authentication exception as listed below.
    https://www.ourdummydomain.com/woo/weepee.png

    System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed

    Any ideas?
     
  49. BestHTTP

    BestHTTP

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

    Unity comes with a really old Mono implementation that contains a somewhat incomplete TLS implementation that can't stand against nowadays expectations. But this is why the plugin comes with a better implementation that you can switch to just by flipping a flag somewhere in your startup code:
    Code (CSharp):
    1. BestHTTP.HTTPManager.UseAlternateSSLDefaultValue = true;
    Most probably it will fix this problem.
     
  50. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
    Well that was fast :)

    Cheers! (that did the trick)