Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Best HTTP Released

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

  1. Ohms

    Ohms

    Joined:
    May 3, 2009
    Posts:
    36
    Hello BestHTTP,

    Can you confirm that the WebSocket, and the using of DELETE and PUT methods works without restrictions on WebPlayer, Android, iOS and WP8 ?

    Did you have planned a release for Windows RT ?
     
  2. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi Ohms.

    All features that you listed are supported on these platforms.

    Windows RT support is on my todo list too, but not planned in the (very) near future.
     
  3. Ohms

    Ohms

    Joined:
    May 3, 2009
    Posts:
    36
    Hello BestHTTP,

    I send you a private message yesterday. Can you confirm that you have received it ?
     
  4. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi Ohms.

    Sorry, but didn't received notification mails on private messages, changed it now and i will check your mail soon too.
     
  5. Ohms

    Ohms

    Joined:
    May 3, 2009
    Posts:
    36
    Thanks for your answer.

    No problem, now I'm sure you will recieve next messages :p
     
  6. taehwa

    taehwa

    Joined:
    Dec 30, 2013
    Posts:
    4
    Hello, Best Http

    How can I set the timeout request?

    If the response is not coming in five seconds, I want to handle the request failed.
     
  7. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi taehwa,

    Unfortunately the TcpClient class that handles the connection to the server hasn't any solution to handle connection timeouts.
     
  8. taehwa

    taehwa

    Joined:
    Dec 30, 2013
    Posts:
    4
    Then, When the network connection is not good, I want to show a pop-up message to the user

    How can I?
     
  9. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi taehwa,

    When connecting a server fails the request's Exception property will be a System.Net.Sockets.SocketException. For a more specific error check you can check the exception's ErrorCode property:

    Code (csharp):
    1. if (req.Exception != null)
    2. {
    3.   SocketException se = req.Exception as SocketException;
    4.   if (se != null)
    5.     Debug.LogError("Error while connecting: " + se.ErrorCode);
    6. }
    7.  
    The ErrorCode property is an Int, for an enumeration you can check this blogpost.
     
  10. asoedarren

    asoedarren

    Joined:
    Jan 8, 2014
    Posts:
    1
    Hi, I also want to set timeout seconds for http request, doesn't mean to connection timeout.
    It likes .net HttpWebRequest timeout parameter.
     
  11. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi asoedarren,

    No such behavior implemented yet, sorry.
     
  12. bschollnick

    bschollnick

    Joined:
    Jan 11, 2014
    Posts:
    6
    Hey Folks,

    I'm considering picking up Best HTTP, since it appears that Unity3d's WWW class doesn't directly support Digest Authentication?

    But I got slightly burnt on purchasing Easy XML, since I can't actually use it for this purpose...

    I'm using this C# code:

    public string xmlPath = "";
    public string xmlContent = "";

    void WebObject(string param)
    {
    xmlPath = param;
    StartCoroutine(DownloadXml());
    }

    IEnumerator DownloadXml()
    {
    Debug.Log ("In Downloader");
    WWW www = new WWW(xmlPath);
    yield return www;
    if (www.error == null)
    Debug.Log ("no errors downloading");
    xmlContent = www.text;
    }

    And it works fine, if I disable the digest authentication...

    The post, here, http://forum.unity3d.com/threads/200006-Best-HTTP-Released?p=1372218&viewfull=1#post1372218 seems to be a digest post?
    Could you give me an idea on what changes I would need to make to the code to allow it to run under Best HTTP?

    I see from the other post the credentials, but I want to try to ensure that I'll be able to use this with minimal fuss.

    Is there a demo available?

    - Ben
     
  13. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi bschollnick,

    Yes, Digest authentication is supported too.
    Your code would look like this with BestHTTP:
    Code (csharp):
    1.     public string xmlPath = "";
    2.     public string xmlContent = "";
    3.  
    4.     void WebObject(string param)
    5.     {
    6.         xmlPath = param;
    7.  
    8.         // Set up the request object
    9.         var request = new HTTPRequest(new Uri(xmlPath), OnFinished);
    10.         request.Credentials = new Credentials("username", "password");
    11.         request.Send();
    12.     }
    13.  
    14.     void OnFinished(HTTPRequest request, HTTPResponse response)
    15.     {
    16.         // Check for errors:
    17.         if (response == null)
    18.         {
    19.             Debug.LogError("No response received: " + request.Exception.ToString() + "\n\r" + request.Exception.Message + "\n\r" + request.Exception.StackTrace);
    20.             return;
    21.         }
    22.  
    23.         xmlContent = response.DataAsText;
    24.     }
    25.  
    If you send me an email address in private i will send you a basic edition, so you can try it out the plugin.
     
  14. bschollnick

    bschollnick

    Joined:
    Jan 11, 2014
    Posts:
    6
    Is there a method that Best HTTP can be used without the call back, or that it yields until the download as finished?

    I'm debugging an issue, and these are small files, so there shouldn't be a significant delay here...

    I can see that the files is being loaded into xmlContent, but when I go to parse it, I am getting XML errors...

    Code (csharp):
    1.  
    2. System.Xml.XmlElement
    3. UnityEngine.Debug:Log(Object)
    4. xmlLoader:ParseDevices_XML(String) (at Assets/xmlLoader.cs:70)
    5. xmlLoader:OnFinishedDeviceDownload(HTTPRequest, HTTPResponse) (at Assets/xmlLoader.cs:45)
    6. BestHTTP.HTTPRequest:CallCallback()
    7. BestHTTP.HTTPConnection:HandleCallback()
    8. BestHTTP.HTTPManager:OnUpdate()
    9. BestHTTP.HTTPUpdateDelegator:LateUpdate()
    10.  
    So I can't tell if some Lazy Load mechanism is causing an error, or if it's a code issue.
     
  15. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi bschollnick.

    There are no yields or such. But you can log out the content of the response in the callback function, or just take a brakepoint in monodevelop and check its values.

    I forgot to mention that when you are using authentication you should check the response's StatusCode for authentication failures.
    So a modified callback code would look like this:
    Code (csharp):
    1.     void OnFinished(HTTPRequest request, HTTPResponse response)
    2.     {
    3.         // Check for errors:
    4.         if (response == null)
    5.         {
    6.             Debug.LogError("No response received: " + request.Exception.ToString() + "\n\r" + request.Exception.Message + "\n\r" + request.Exception.StackTrace);
    7.             return;
    8.         }
    9.  
    10.         // Check for authentication failure
    11.         if (response.StatusCode == 401)
    12.             Debug.LogError("Authentication failed: " + response.Message);
    13.         else
    14.         {
    15.             // Print out what we downloaded:
    16.             Debug.Log(response.DataAsText);
    17.  
    18.             xmlContent = response.DataAsText;
    19.         }
    20.     }
    I think i should mention that the DataAsText property is converting the raw data to an utf8 string. You can access this raw data with the Data property if an other conversion is more suitable for you.
     
  16. cjimison

    cjimison

    Joined:
    Jan 4, 2014
    Posts:
    11
    Hi,

    I bought a copy of the BestHTTP pro package and I really like the direction you went with your API's and system in general. Everything works fine if I include the code directly inside of the Unity Project, however when I try to build my own DLL I get the following errors.

    Internal compiler error. See the console log for more information. output was:
    Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
    at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
    at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
    at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
    at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
    at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0
    at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
    at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0

    I was hoping to keep the code out of the base game package if possible and any help would be appreciated.

    Thanks!
     
  17. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi cjimison

    You need to move the Plugins folder from the Best Http (Pro/Basic) folder to your Assets folder, so Unity can find it.
     
  18. cjimison

    cjimison

    Joined:
    Jan 4, 2014
    Posts:
    11
    > You need to move the Plugins folder from the Best Http (Pro/Basic) folder to your Assets folder, so Unity can find it.

    I did that as well. Sorry I should have said so. Basically what I have done is the following:

    * In MonoDevelop create a new library project called "BestHTTP".
    * Copy and pasted your source code into the project.
    * In the MonoDevelop project references I added the TcpClientImplementation.DLL
    * Compiled a DLL from the project.
    * Copied over the "BestHTTP" dll and the TcpClientImplementation.DLL into the "Plugins" folder in Unity.

    Then I get the above set of errors.
     
  19. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    I see now, thx.

    Basically these are the steps that i do when I'm making the Basic version of the plugin, except that i used Visual Studio. But i don't think that should be the problem.
    I'm at work right now, but i will check it later this day, maybe a little step is missing.
     
  20. cjimison

    cjimison

    Joined:
    Jan 4, 2014
    Posts:
    11
    Thanks and I appreciate the help. Also one step I forgot to list is adding both UnityEngine.dll and UnityEditor.dll as a reference to the project as defined in the steps on:

    http://docs.unity3d.com/Documentation/Manual/UsingDLL.html

    I also tried only adding the UnityEngine.dll as a reference with the same results.
     
  21. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi cjimison.

    It was easy to reproduce the problem with MonoDevelop. And the problem is MonoDevelop itself. :)
    On the Project Options/Build/General tab the Target framework must be set to to Mono/ .Net 3.5.

    But (here is the catch:)) if you compile it now, you will receive some compile error. I'm using the Named and Optional Arguments feature of the C# language, but it's turned out that it's a C# 4.0 language feature (not framework, it's a language version).
    So it worked while i compiled in VS 2010(or newer) and Unity, but in MonoDevelop it's a no-go. On the same tab that you can change the Target framework there is a Language Options section where you can change the C# Language Version, but when i tried to change to 4 or 5 i got a compile error saying "error CS1617: Invalid option '5' for /langversion; must be ISO-1, ISO-2 or Default"...
    I don't know what compiler option Unity uses to compile the code.

    So how you will get a working dll?
    1. You can remove the default parameters, then add it where it's missing. (It's just a couple moments of work.)
    2. I will send you the modified source files without the default parameters, and you can still compile the dll yourself.
    3. I will send you the Basic version of the plugin and you can use the dlls from it. (The Basic version has all the features that the Pro has.)
    4. You can wait for the next update.
    5. Maybe you can figure it out whats wrong with MonoDevelop, and you can compile it without removing the default parameters.
    6. Just compile it with Visual Studio. (Well, it's not an easiest solution if you are on Mac OS. :))
     
  22. Flyclops

    Flyclops

    Joined:
    Apr 19, 2013
    Posts:
    12
    Does BestHTTP support both gzip compressing requests and decompressing responses?
     
  23. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi Flyclops.

    Only decompressing responses supported, as i doesn't know any amend to the standard to compressing requests.
    But you can compress your data before uploading any time. Or using the Pro edition it wouldn't be too hard to implement automatic compression of the data.
     
  24. junk1er

    junk1er

    Joined:
    Feb 11, 2014
    Posts:
    4
    Hi!

    Can I cache downloaded images to hard drive using BestHTTP?
    After that, manage cache folder, clear it on application quit?
     
  25. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi junk1er.

    Caching is done automatically by BestHTTP. If the server's response is allowing it, it will cache the received responses than the consecutive requests will try to validate the cached content using If-None-Match for ETag and If-Modified-Since. Or bypassing the validation if a Max-Age set, and the cached entry didn't expired yet.

    Managing can be done through the BestHTTP.Caching.HTTPCacheService class. You can set the maximum size of the entire cache and delete older cached entries through the BeginMaintainence function:
    Code (csharp):
    1. // Delete cached items that older then 2 days, and set the maximum size of the cache to 10 Mb
    2. BestHTTP.Caching.HTTPCacheService.BeginMaintainence(new BestHTTP.Caching.HTTPCacheMaintananceParams(TimeSpan.FromDays(2), 10 * 1024 * 1024));
    Also, clearing the cache can be done with the BeginClear function:
    Code (csharp):
    1. BestHTTP.Caching.HTTPCacheService.BeginClear();
    These are non-blocking functions, they will do the job in the background. Using the BeginMaintainence function is more helpful if you place it when the application starts, while calling the BeginClear should be a little before exiting.

    If you have more questions, don't hesitate to ask.
     
  26. cjimison

    cjimison

    Joined:
    Jan 4, 2014
    Posts:
    11
    Quick question: Is a call to WebSocket.Send a blocking or non-blocking call?

    Thanks!
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi cjimison.

    The WebSocket.Send is a blocking call, but you can use a class like this to make it non-blocking:

    Code (csharp):
    1.     public class WSConsumer
    2.     {
    3.         private class QueueData
    4.         {
    5.             public string Message { get; set; }
    6.             public byte[] Data { get; set; }
    7.  
    8.             public QueueData(string message)
    9.             {
    10.                 this.Message = message;
    11.                 this.Data = null;
    12.             }
    13.  
    14.             public QueueData(byte[] data)
    15.             {
    16.                 this.Message = null;
    17.                 this.Data = data;
    18.             }
    19.         }
    20.  
    21.         public WebSocket WebSocket { get; private set; }
    22.  
    23.         private System.Collections.Generic.Queue<QueueData> Queue = new System.Collections.Generic.Queue<QueueData>();
    24.         private System.Threading.AutoResetEvent ResetEvent = new System.Threading.AutoResetEvent(false);
    25.         private object SyncObject = new object();
    26.         private bool Started = false;
    27.  
    28.         public WSConsumer(WebSocket ws)
    29.         {
    30.             this.WebSocket = ws;
    31.  
    32.             if (ws.IsOpen)
    33.                 StartThread();
    34.             else
    35.                 this.WebSocket.OnOpen += OnOpen;
    36.  
    37.             this.WebSocket.OnClosed += OnClosed;
    38.         }
    39.  
    40.         public void Send(string message)
    41.         {
    42.             lock(SyncObject)
    43.             {
    44.                 Queue.Enqueue(new QueueData(message));
    45.                 ResetEvent.Set();
    46.             }
    47.         }
    48.  
    49.         public void Send(byte[] data)
    50.         {
    51.             lock (SyncObject)
    52.             {
    53.                 Queue.Enqueue(new QueueData(data));
    54.                 ResetEvent.Set();
    55.             }
    56.         }
    57.  
    58.         private void StartThread()
    59.         {
    60.             Started = true;
    61.             System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadFunc));
    62.             lock (SyncObject)
    63.                 if (Queue.Count > 0)
    64.                     ResetEvent.Set();
    65.         }
    66.  
    67.         private void OnOpen(WebSocket ws)
    68.         {
    69.             StartThread();
    70.         }
    71.  
    72.         private void OnClosed(WebSocket ws, UInt16 code, string message)
    73.         {
    74.             // Signal the thread, so we can exit from it.
    75.             ResetEvent.Set();
    76.         }
    77.  
    78.         private void ThreadFunc(object param)
    79.         {
    80.             while (WebSocket.IsOpen)
    81.             {
    82.                 ResetEvent.WaitOne();
    83.  
    84.                 lock(SyncObject)
    85.                 {
    86.                     while(Queue.Count > 0)
    87.                     {
    88.                         QueueData data = Queue.Dequeue();
    89.                        
    90.                         if (!string.IsNullOrEmpty(data.Message))
    91.                         {
    92.                             WebSocket.Send(data.Message);
    93.                         }
    94.                         else if (data.Data != null)
    95.                         {
    96.                             WebSocket.Send(data.Data);
    97.                         }
    98.                     }
    99.                 }
    100.             }
    101.  
    102.         }
    103.     }
    To use this class just create a new instance from it, passing the original WebSocket, then use the Send functions to send messages:
    Code (csharp):
    1. webSocket = new WebSocket(new Uri(address));
    2. webSocket.OnOpen += OnOpen;
    3. webSocket.OnMessage += OnMessageReceived;
    4. webSocket.OnClosed += OnClosed;
    5. webSocket.OnError += OnError;
    6.  
    7. consumer = new WSConsumer(webSocket);
    8. consumer.Send("Text Message");
    9.  
    10. webSocket.Open();
    As you can see, you can even use the Send function before the WebSocket is opened. :)
     
  28. junk1er

    junk1er

    Joined:
    Feb 11, 2014
    Posts:
    4
    Hi BestHTTP!

    Thank you for your useful response.
    My next questions are:
    1) Can I use HTTPRequest's 'Tag' property for managing cached images? For example, clear all cached responses for tag 'Avatars' ?
    2) How can I abort/stop HTTPRequest if I have a reference to instance?

    Thank you!
     
  29. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    1) 'Tag's are for distinguish requests if one callback are used for more than one request. But if you have the Pro version, in the HTTPCacheService.cs there are an internal DeleteEntity function that you can make it public. This way, you can delete the cached entry (if there are any) passing a request's URI,
    This way you still have to manage the tagged URIs, though.

    2) There are no way no to abort a request now. But already on my TODO list, I think i will do it after the Windows Store App support is completed.
     
  30. Vedad

    Vedad

    Joined:
    Sep 29, 2011
    Posts:
    29
    Hello BestHTTP.

    Firstly, thank you for this package! It's been very helpful.

    I'm having problem with the WebSocket class.

    Here is my current setup:
    -Amazon EC2 instance running Ubuntu 12.04
    -Node.js version 0.10.26
    -Unity 4.3.4f1

    The socket policy is being fetched just fine whether I use UnityEngine.Security.PrefetchSocketPolicy() it or when I attempt to call WebSocket.Open(). I'm using a socket policy server for that. I'm getting stuck with actually establishing a connection between the server and client. I have to admit, I am fairly inexperienced with socket connections and this is my first time messing with the socket.io module. I've opened up all the ports for inbound and outbound traffic on the server as well.

    This is my javascript code on the server which should establish socket connections:
    Code (csharp):
    1. var http = require('http');
    2.  
    3. var app;
    4.  
    5. module.exports = function(config)
    6. {  
    7.     app = config.app;
    8.  
    9.     var server = http.createServer(app);
    10.  
    11.     var io = require('socket.io').listen(server);
    12.  
    13.     io.sockets.on('connection', function (socket)
    14.     {
    15.         console.log('connection in socket');
    16.     });
    17.  
    18.     console.log('listening for socket connections started');
    19. };
    This is where my server is actually created:
    Code (csharp):
    1. var express = require('express');
    2. var app = express();
    3.  
    4. var config = {app:app, express:express};
    5.  
    6. //Socket server
    7. require('./socket.js')(config);
    8.  
    9. app.use(express.bodyParser());
    10.  
    11. //Returns http crossdomain policy
    12. app.get('/crossdomain.xml', function(req,res,next){
    13.     console.log('socket crossdomain.xml');
    14.     res.send('<?xml version="1.0"?><cross-domain-policy><allow-access-from domain="*"/></cross-domain-policy>');
    15. });
    16.  
    17. console.log('http server listening on port 8888');
    18.  
    19. app.listen(8888);
    I'm using the WebSocketTestScene provided in the BestHTTP (Pro) version. With some modifications to test my server. Here is that code:
    Code (csharp):
    1.  
    2.     //I've tried appending this with :8888 but still the same outcome.
    3.     string address = "wss://MY-PUBLIC-DNS.amazonaws.com";
    4.     string Text = string.Empty;
    5.  
    6.     WebSocket webSocket;
    7.  
    8.     void OnGUI()
    9.     {
    10.         GUILayout.BeginVertical();
    11.         GUI.TextArea(new Rect(5, 10, Screen.width - 10, Screen.height - 180), Text);
    12.         GUILayout.EndVertical();
    13.  
    14.         address = GUI.TextField(new Rect(5, Screen.height - 160, Screen.width - 10, 30), address);
    15.  
    16.         if(GUI.Button(new Rect(5, Screen.height - 120, Screen.width - 30, 30),"Init"))
    17.         {
    18.             bool prefetch = UnityEngine.Security.PrefetchSocketPolicy("MY-PUBLIC-IP", 843);
    19.            
    20.                 Debug.Log("prefetch result : " + prefetch);
    21.         }
    22.  
    23.         if (webSocket == null  GUI.Button(new Rect(5, Screen.height - 65, 120, 60), "Open Web Socket"))
    24.         {
    25.             webSocket = new WebSocket(new Uri(address));
    26.             webSocket.OnOpen += OnOpen;
    27.             webSocket.OnMessage += OnMessageReceived;
    28.             webSocket.OnClosed += OnClosed;
    29.             webSocket.OnError += OnError;
    30.  
    31.             webSocket.Open();
    32.  
    33.             Text += "Opening Web Socket...\n";
    34.         }
    35.     }
    The response is always the same: "An error occured: Connection timed out"

    I've been looking for answers all day but can't seem to figure out what I'm doing wrong. Hopefully someone can shed some light on what the problem here might be. I guess the first question would be what kind of response is the WebSocket.Open() expecting? Any input would be appreciated! Thank you!

    Sorry if this is long, I couldn't figure out how to collapse these code blocks.
     
  31. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    Does Best HTTP work with unity free?
     
  32. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    HI Vedad.

    1.) I'm not familiar with Node,js' Socket.IO, but are you sure that it's not for Socket.IO and can be used to WebSockets too? WebSockets and Socket.IO are two different things, although Socket.IO can be used on top of WebSockets. I used the 'WebSocket' module on Node.js to some of my tests.

    2.) The 'wss' prefix in your address indicates that the connection will be made through port 443 instead of 80. If you do not have ssl set up for HTTPS, than you should use the 'ws' prefix:
    Code (csharp):
    1. string address = "ws://MY-PUBLIC-DNS.amazonaws.com";
    3.) If you are not using this code in webplayer, than you don't have to set up a socket policy server.
     
    Last edited: Mar 10, 2014
  33. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi Zaddo67.

    I just wanted to try it out this weekend, but i had no time left for it. If you send me a private message with your mail address i will send you a Basic version so you can try it out.
    I would be happy too to find it out. :)
     
    Last edited: Mar 10, 2014
  34. Vedad

    Vedad

    Joined:
    Sep 29, 2011
    Posts:
    29
    Thank you for your response! I knew I just needed someone to nudge me in the right direction. I removed the socket.io module, and implemented the WebSocket module, and with some minor modifications got it up and running and working with your package! Can't stress this enough, you've saved me a lot of head-aches!
     
  35. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Great! I'm happy that i was able to help!
     
  36. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    BestHTTP Generously let me try his package in Unity Free before buying. Unfortunately the HTTP sockets is a pro only feature and so Best HTTP won't work in Unity Free. Unity stops you from building an APK unless you have pro.

    I was able to play with Best HTTP in the editor. The demo's all worked first time and what I saw looked nice.
     
  37. cjimison

    cjimison

    Joined:
    Jan 4, 2014
    Posts:
    11
    Thanks for such a detailed response! While I already have a worker thread model implemented, I really like your queue management for possible temporary disconnect handling (for things like mobile players who are going through a tunnel on the train, etc).
     
  38. cjimison

    cjimison

    Joined:
    Jan 4, 2014
    Posts:
    11
    Hi,

    Just wondering if anyone else has bumped into this issue. When trying to run our game with any Code Stripping level other then none I get the following error on android:

    03-13 17:12:55.420 com.COMP.GAME 12325 12340 I Unity Unknown Exception Type System.TypeInitializationException: An exception was thrown by the type initializer for System.Net.Sockets.Socket ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.Configuration.ExeConfigurationHost'.
    03-13 17:12:55.420 com.COMP.GAME 12325 12340 I Unity at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
    03-13 17:12:55.420 com.COMP.GAME 12325 12340 I Unity at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
    03-13 17:12:55.420 com.COMP.GAME 12325 12340 I Unity at System.Configuration.InternalConfigurationSystem.Init (System.Type typeConfigHost, System.Object[] hostInitParams) [0x00000] in <filename unknown>:0
    03-13 17:12:55.420 com.COMP.GAME 12325 12340 I Unity at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
    03-13 17:12:55.420 com.COMP.GAME 12325 12340 I Unity at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel

    Any help would be greatly appreciated!

    I am building BestHttp from source on a Mac using unity 4.3.4, device is a Nexus 5 on Android KitKat.

    Thanks!

    UPDATE:

    Just tried it on iOS as well. Everything works with no stripping and then when stripping is enabled connections fail.
     
    Last edited: Mar 14, 2014
  39. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi cjimison.

    Several months ago received a mail about this issue, back then after several mails I suggested to use parts of this link.xml, then I never received an asnwer.
    I don't know what should be the problem, as I can't reproduce this. All stripping levels are working for me. :/
     
  40. Flyclops

    Flyclops

    Joined:
    Apr 19, 2013
    Posts:
    12
    Hi again,

    We got Pro and it was very easy to implement. So thanks.

    One question, we use Charles as a debugging proxy to test our network calls, but calls made through BestHTTP are not showing up. Do you know if there's any setting we can change to see them.

    Thanks again,
    Jake
     
  41. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi Flycops.

    There are no proxy support yet in BestHTTP, but it's climbing up on my to-do list.

    Edit: I managed to create a quick proxy implementation. If you send me your mail address in a private message here at the forums, or to my mail address i will send you the modified files. And anyone with a Pro version can test it the same way.
     
    Last edited: Mar 22, 2014
  42. Flyclops

    Flyclops

    Joined:
    Apr 19, 2013
    Posts:
    12
    Thanks! Will do.
     
  43. fingersbleeding

    fingersbleeding

    Joined:
    Jun 10, 2013
    Posts:
    24
    We've found that publishing to Android or iOS with BestHTTP requires Unity Pro + both the iOS Pro an Android Pro plugins. The culprit seems to be System.Net.Sockets included in the TcpClientImplementation dll / pdb files.

    Error building Player: SystemException: 'System.Net.Sockets' are supported only with Unity Android Pro. Referenced from assembly 'TcpClientImplementation'.

    We removed the W8 TcpClientImplementation, but still get the error. Removing the other TcpClientImplementation files from Plugins creates a new error.

    Assets/BestHTTP/BestHTTP/HTTPConnection.cs(16,7): error CS0246: The type or namespace name `Org' could not be found. Are you missing a using directive or an assembly reference?

    Is there a way to remove the dependency on System.Net.Sockets in TcpClientImplementation?

    Thanks,

    Jason
     
  44. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi fingersbleeding.

    I'm sorry, but i don't know any way to circumvent the Socket dependency.
     
  45. fingersbleeding

    fingersbleeding

    Joined:
    Jun 10, 2013
    Posts:
    24
    My apologies, I read through this thread and saw a few posters questioning what version of Unity BestHTTP supported. After I read through to the bottom of the documentation available on Google Docs, I see you've listed iOS and Android support with their respective Pro licenses.

    Is there any way around this? Is BestHTTP reliant on System.Net.Sockets for basic HTTPS requests? We're simply looking for a WWW replacement that's more reliable and thought this could be an option. Since we can't outfit our entire team with pro packagers for our cross-platform mobile games, if this isn't an option in BestHTTP, have you come across any other libraries that were strong in your opinion?
     
  46. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Maybe you can try out this Good ol' Sockets asset.
    If it's not working with BestHTTP, then you may try out UniWeb with Good ol' Sockets.
     
  47. Davide1104

    Davide1104

    Joined:
    Jun 12, 2013
    Posts:
    38
    Hi, I have buy your Asset today.

    I would like to create a local server on OSX able to give back to those who connect to it via smartphone browser wifi to a page html5 that allows you to communicate with stadalone Unity app on OSX.
    you can do with this asset?
    I have read the documentation pdf, but I still have much to understand
    Where can I find further documentation books and/or video tutorials?

    Thanks

    (sorry for my english)
     
  48. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi Davide78d.

    I would recommend Node.js. It's a cross platform, easy to use web server with great tools and community.
    For getting started i recommend these great answers from StackOverflow.
    With Node.js you will be able to create a web service to communicate with your app.
     
  49. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,666
    Hi fingersbleeding.

    As you may already know that the Good ol' Sockets created was kind enough to test my plugins, and both of them are worked fine with the Free version of Unity!
     
  50. klund

    klund

    Joined:
    Mar 21, 2011
    Posts:
    33
    Hi Just purchased the Proversion of BestHttp

    I am using Unity 4.3
    After moving the plugin folder to the Asset folder I still get

    "Internal compiler error. See the console log for more information. output was:
    Unhandled Exception: System.TypeLoadException: Could not load type 'SocketEx.TcpClient' from assembly 'TcpClientImplementation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. "

    In Monodevelop says
    Assets/Scripts/Best HTTP (Pro)/BestHTTP/HTTPConnection.cs(28,28): Error CS0584: Internal compiler error: Method not found: 'SocketEx.TcpClient.get_Client'. (CS0584) (Assembly-CSharp)

    However when I right click on the method the IDE opens on the method it says that it cannot find

    Any Ideas ?