Search Unity

Best HTTP Released

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

  1. Davide1104

    Davide1104

    Joined:
    Jun 12, 2013
    Posts:
    27
    thanks
    but, maybe I have not explained very well
    I need to create a local server that run inside unity3d standalone OSX and controlled by socket web -> iphone browser web

    so. i need to connect local unity3D OSX to iphone browser-web (by web-socket ?)

    node.js run on external web server online and not inside Unity3d, right?!
     
    Last edited: Apr 1, 2014
  2. klund

    klund

    Joined:
    Mar 21, 2011
    Posts:
    33
    To solve the issue i compiled the source which worked after solving the following issues in the source
    1) the equals line confues the compiler because it tries to use the protected equals instead of the public. To fix this is casted to object. PLEASE FIX this permanently
    publicoverrideECFieldElementSqrt() {
    if (!q.TestBit(0))
    throwPlatform.CreateNotImplementedException("even value of q");

    //pmod4 == 3
    if (q.TestBit(1)) {
    //TODOCanthisbeoptimised (inlinetheSquare?)
    //z = g^(u+1) + p, p = 4u + 3
    ECFieldElementz = newFpFieldElement(q, x.ModPow(q.ShiftRight(2).Add(BigInteger.One), q));

    //@todoKLtheauthorhasaprotectedvspublicissuewhencompilingonmonodeveloper
    //returnz.Square().Equals(this) ? z : null;
    returnz.Square().Equals(this as object) ? z : null;
    }

    2) the WP8 TCPClient is also included in the source so
    TCPClient is defined twice. => must be som macro #if #endif issue

     
  3. BestHTTP

    BestHTTP

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

    Thank you for clarify your problem.
    Sorry, but creating a web server is the opposite of my plugin's intention. My plugin can act only as a web client, you can't turn it to a web server.
     
  4. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi klund.

    Unity can act up strangely sometimes. For me moving the Plugin folder to the Assets folder always enough, but sometimes there might need a Unity restart too.
     
  5. rejwan1

    rejwan1

    Joined:
    Jul 3, 2012
    Posts:
    35
    Hello,

    We're using Unity 4.2 - we just bought your pro version, after importing to the project we get the following error (can't even run the game):

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

    at (wrapper managed-to-native) System.MonoType:GetMethodsByName (string,System.Reflection.BindingFlags,bool,System.Type)

    at System.MonoType.GetMethods (BindingFlags bindingAttr) [0x00000] in <filename unknown>:0

    at Mono.CSharp.MemberCache.AddMethods (BindingFlags bf, System.Type type) [0x00000] in <filename unknown>:0

    at Mono.CSharp.MemberCache.AddMethods (System.Type type) [0x00000] in <filename unknown>:0

    at Mono.CSharp.MemberCache..ctor (IMemberContainer container) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeHandle..ctor (System.Type type) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeHandle.GetTypeHandle (System.Type t) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeHandle.GetMemberCache (System.Type t) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, MemberTypes mt, BindingFlags bf, System.String name, System.Boolean used_cache) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeManager.RealMemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeManager.MemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Expression.MemberLookup (Mono.CSharp.CompilerContext ctx, System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Expression.MemberLookup (Mono.CSharp.CompilerContext ctx, System.Type container_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Binary.ResolveUserOperator (Mono.CSharp.ResolveContext ec, System.Type l, System.Type r) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Binary.ResolveOperator (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Binary.DoResolveCore (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression left_orig, Mono.CSharp.Expression right_orig) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Binary.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Binary.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Expression.ResolveBoolean (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression e, Location loc) [0x00000] in <filename unknown>:0

    at Mono.CSharp.If.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TryCatch.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TryFinally.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

    at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.FlowBranching parent, Mono.CSharp.BlockContext rc, Mono.CSharp.ParametersCompiled ip, IMethodData md) [0x00000] in <filename unknown>:0
     
  6. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi rejwan1.

    Have you moved the Plugins folder to the Assets folder?
    After this step, you also should restart Unity to let it pick the right dll.
     
  7. rejwan1

    rejwan1

    Joined:
    Jul 3, 2012
    Posts:
    35
    Yep that was it, also read the documentation and I feel silly now :)
     
  8. Eskema

    Eskema

    Joined:
    Jun 23, 2010
    Posts:
    313
    Hi,

    Does this plugin allows to reuse calls?, I fear the garbage collector....

    Example with unity, (pretty rough)
    Code (csharp):
    1.  
    2. int id = 10;
    3. string json = "{\"nameID\":" + id + "}" ;
    4. byte[] data = encoding.GetBytes(json);
    5. WWW loadWWW = new WWW(url, data, headers);
    6.  
    Each time I need to call the rest service I need to create a new www call, when I just need to update the data passed. Imagine a game like pokemon, each time I see a pokemon I send a call to the webserver like this, "http://www.server.com/getinfo/pokemonName" and this will return a json/xml with the pokemon info.

    So, in my calls the only data that changes is the json I send to the webserver, so it will be useful if the www call can be reused and just change the data in the post/get method.

    Is this possible at all?
     
  9. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi Eskema.

    Yes, you can use something like this to reuse a request:
    Code (csharp):
    1.     HTTPRequest reusedReuqest = null;
    2.     int id = 10;
    3.     void ReuseTest()
    4.     {
    5.         if (reusedReuqest == null)
    6.         {
    7.             reusedReuqest = new HTTPRequest(new Uri("http://besthttp.azurewebsites.net/api/Reuse"), HTTPMethods.Post,
    8.                 (req, resp) => Debug.Log("" + resp.StatusCode + " " + resp.Message + " " + resp.DataAsText));
    9.             reusedReuqest.SetHeader("Content-Type", "application/json");
    10.         }
    11.  
    12.         string json = "{\"nameID\":" + id++ + "}" ;
    13.  
    14.         reusedReuqest.RawData = UTF8Encoding.UTF8.GetBytes(json);
    15.  
    16.         reusedReuqest.Send();
    17.     }
    18.  
    But sending, parsing the result will generate some additional GC allocations.
     
    Last edited: Apr 3, 2014
  10. Eskema

    Eskema

    Joined:
    Jun 23, 2010
    Posts:
    313
    Thanks, I'm aware that I have to waste GC parsing the json, but at least I can save a few allocations reusing the request which is something that unity doesn't allow (thus my original question).
    Time to buy this plugin and take a look at how it works :)
     
  11. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    New updates are pushed live(1.3.x). Basic and Pro versions are both updated.

    This update contains the new Proxy implementation. With the help of a proxy you can see the requests and responses that your app makes.
    It's comes with proxy authentication too, but it's highly experimental.

    Code (csharp):
    1.  
    2. var request = new HTTPRequest(new Uri("https://www.google.com"), (req, resp) => Debug.Log("Connected through proxy!"));
    3. request.Proxy = new HTTPProxy(new Uri("http://localhost:3128"));
    4. request.Send();
    5.  
    The next more frequently requested feature was Cookie support. Cookies are now automatically handled by the plugin. They can be disabled/enabled globally(through the HTTPManager static class), or per request. Also cookies are persisted through app restarts.

    Cookie example:
    Code (csharp):
    1. var request = new HTTPRequest(new Uri("http://google.com"), (req, resp) =>
    2. {
    3.     if (resp == null)
    4.     {
    5.         Debug.LogError("No response received: " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
    6.         return;
    7.     }
    8.  
    9.     Debug.Log(string.Format("{0} {1} {2}: {3}", req.CurrentUri, resp.StatusCode, resp.Message, resp.DataAsText));
    10.  
    11.     Debug.Log("Sent Cookies:");
    12.     var sent = req.GetHeaderValues("Cookie");
    13.     if (sent != null) // Cookies are merged into one header, so it should display only one here
    14.         foreach (var sentCookie in sent)
    15.             Debug.Log(sentCookie);
    16.  
    17.     Debug.Log("Received Cookies:");
    18.     if (resp.Cookies != null)
    19.         foreach (var cookie in resp.Cookies)
    20.             Debug.Log(cookie.ToString());
    21. });
    22.  
    23. request.Send();
    Also you can enable/disable private "browsing". If Private Browsing is on, cookies that are received while it's on are not saved:
    Code (csharp):
    1. HTTPManager.EnablePrivateBrowsing = true;
    You can completely disable cookies by setting HTTPManager.IsCookiesEnabled to false:
    Code (csharp):
    1. HTTPManager.IsCookiesEnabled = false;
     
  12. themartorana

    themartorana

    Joined:
    Mar 5, 2013
    Posts:
    3
    Howdy,

    Because of the Heartbleed bug, we updated our SSL cert - rekeyed it, that is - through GoDaddy. We were encouraged to select SHA-2 signature algorithm. When we loaded the new SSL cert on to our load balancer, Best HTTP dropped every single request, but no errors were produced - just an empty response. The requests never got past the load balancer to the web or app server, which lead us to believe there was a problem with the new certificate.

    I re-rekeyed our SSL cert today using the older SHA-1 signature algorithm, and everything worked appropriately.

    Not working: SHA-256 with RSA Encryption ( 1.2.840.113549.1.1.11 )
    Working: SHA-1 with RSA Encryption ( 1.2.840.113549.1.1.5 )

    Does Best HTTP support SHA-2 fully? I can switch the certificates at whim, and when we do, the behavior is completely reproducible on our side.

    Thanks!
     
  13. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi themartorana.

    Unfortunatly the mono version that shipped with Unity lacking with this support of encryption. I can't do anything about it, sadly.
    However, you can try to switch to an alternate implementation that came with my plugin by setting the UseAlternateSSL of the request to true:
    Code (csharp):
    1. var req = new HTTPRequest(....);
    2. req.UseAlternateSSL = true;
    3. req.Send();
    This will use the Bouncy Castle library.

    But, becouse i found this implementation unreliable sometimes i have to say that my advice is to stick with SHA-1, but it is best to test it yourself maybe you will find it good enough.

    Regards.
     
  14. themartorana

    themartorana

    Joined:
    Mar 5, 2013
    Posts:
    3
    Hey, thanks for the quick reply!

    I'll take a look at using Bouncy Castle, but it looks like that library is from 2011. For now, we're back on SHA-1, but our registrar (and others) is/are beginning to require renewals and new certs be SHA-2. Once we hit that requirement, we'll have to figure something out.

    Thanks again,

    Dave
     
  15. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Maybe in newer versions it will be added. (Fingers crossed. :))
     
  16. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
  17. Jakil

    Jakil

    Joined:
    May 14, 2012
    Posts:
    2
    Hello,

    I've just bought BestHTTP and since it uses Callbacks, I wonder if I can write a method to directly return the value of an HTTP Get request.

    Code (csharp):
    1. public static string GetResponse(string StrURL)
    2. {
    3.  
    4. ...
    5.  
    6. }
     
  18. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi Jakil.

    If you want to write something like this:

    Code (csharp):
    1. public static string GetResponse(string StrURL)
    2. {
    3.   var request = new HTTPRequest(new Uri(StrURL), OnFinished);
    4.   request.Send();
    5.   // Wait somehow to OnFinished called
    6.  
    7.   return request.Response.DataAsText;
    8. }
    9.  
    10. public static void OnFinished(HTTPRequest request, HTTPResponse response)
    11. {
    12.  
    13. }
    14.  
    Then you can do it with a ManualResetEvent. But i would highly discourage you, becouse it would block the whole calling chain.

    Code (csharp):
    1. public static string GetResponse(string StrURL)
    2. {
    3.   var request = new HTTPRequest(new Uri(StrURL), OnFinished);
    4.   request.Send();
    5.  
    6.   // Wait
    7.   ManualResetEvent mre = new ManualResetEvent(false);
    8.   request.Tag = mre;
    9.  
    10.   mre.WaitOne();
    11.   mre.Close();
    12.  
    13.   return request.Response.DataAsText;
    14. }
    15.  
    16. public static void OnFinished(HTTPRequest request, HTTPResponse response)
    17. {
    18.   ManualResetEvent mre = request.Tag as ManualResetEvent;
    19.   mre.Set();
    20. }
    21.  
     
  19. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    It's live now on the Asset Store.
     
  20. drakein

    drakein

    Joined:
    Sep 18, 2012
    Posts:
    1
    Is there anyway to cancel a connection once it's going? Or a way to time it out?

    I've got a big download, and if you lose connection, or the server goes down, there's no failure response, and a connection just stays open. It'd be nice if I could manual cancel a download that's stuck, or have it done through the library automatically.
     
  21. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi drakein.

    There is no way to cancel a connection/download now, but I'm planning to do it after finished with the Windoes Store App support.
     
  22. Jool

    Jool

    Joined:
    Jan 17, 2014
    Posts:
    6
    Hello,

    I just want to confirm a little something.

    With BestHTTP Pro I can use Websockets on all platforms right? (Including WebPlayer)

    Thanks.
     
  23. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi Jool.

    Yes, all platforms are supported including WebPlayer builds. But in a WebPlayer build you have to set up a Socket Policy Service on the server that you want to access.
    Please read the Unity Manual's Implications for use of Sockets section.
     
  24. Jool

    Jool

    Joined:
    Jan 17, 2014
    Posts:
    6
    Ok great,

    I was reading about the Socket Policy Service today.

    Regarding the server code, is it ok to develop it with Alchemy websockets on top of ASP.Net MVC or would you advise another framework?
     
  25. s0phist

    s0phist

    Joined:
    Mar 30, 2011
    Posts:
    31
    I'm running into the following error every time I make a code change on Unity 4.5:


    Code (CSharp):
    1.  
    2. -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp-Editor.dll
    3. Missing method .ctor in assembly /Users/acgourley/propel/nexus/Assets/Best HTTP (Basic)/Plugins/WP8/TcpClientImplementation.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
    4. The class System.Runtime.Versioning.TargetFrameworkAttribute could not be loaded, used in TcpClientImplementation
    5. Can't find custom attr constructor image: /Users/acgourley/propel/nexus/Assets/Best HTTP (Basic)/Plugins/WP8/TcpClientImplementation.dll mtoken: 0x0a000005
    6. -----CompilerOutput:-stderr----------
    7.  
    8. Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
    9.  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
    10.  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
    11.  at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
    12.  at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
    13.  at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
    14.  at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0
    15.  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
    16.  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
    17. -----EndCompilerOutput---------------
    18.  
     
  26. DNArt

    DNArt

    Joined:
    Jan 16, 2014
    Posts:
    21
    Hi just bought BestHTTP Pro to find it gives a compile error when installing in a empty new project could you please fix this since its not usable like this.

    I'm using 4.5

    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'.
    at (wrapper managed-to-native) System.MonoType:GetMethodsByName (string,System.Reflection.BindingFlags,bool,System.Type)
    at System.MonoType.GetMethods (BindingFlags bindingAttr) [0x00000] in <filename unknown>:0
    at Mono.CSharp.MemberCache.AddMethods (BindingFlags bf, System.Type type) [0x00000] in <filename unknown>:0
    at Mono.CSharp.MemberCache.AddMethods (System.Type type) [0x00000] in <filename unknown>:0
    at Mono.CSharp.MemberCache..ctor (IMemberContainer container) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeHandle..ctor (System.Type type) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeHandle.GetTypeHandle (System.Type t) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeHandle.GetMemberCache (System.Type t) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, MemberTypes mt, BindingFlags bf, System.String name, System.Boolean& used_cache) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeManager.RealMemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeManager.MemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.MemberLookup (Mono.CSharp.CompilerContext ctx, System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.MemberLookup (Mono.CSharp.CompilerContext ctx, System.Type container_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.ResolveUserOperator (Mono.CSharp.ResolveContext ec, System.Type l, System.Type r) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.ResolveOperator (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.DoResolveCore (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression left_orig, Mono.CSharp.Expression right_orig) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.ResolveBoolean (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression e, Location loc) [0x00000] in <filename unknown>:0
    at Mono.CSharp.If.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TryCatch.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TryFinally.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.FlowBranching parent, Mono.CSharp.BlockContext rc, Mono.CSharp.ParametersCompiled ip, IMethodData md) [0x00000] in <filename unknown>:0
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi folks.

    I was out of office for a week, and with the forum update i didn't received emails that there are new posts here. If you still have these compiler problems please drop me a mail.
     
  28. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    New version uploaded to the Asset Store!

    Changelog:
    • 1.3.5
    [Improvement] Unknown Content-Encoding will be treated as “identity”
    [Improvement] Better WebSocket error handling
    [Improvement] Actualized examples
    [Improvement] link.xml in the package in case of stripping error
    [BugFix] Fixed WebSocket big frame reading error​
     
  29. DNArt

    DNArt

    Joined:
    Jan 16, 2014
    Posts:
    21
    Hi best HTTP

    I still get a screen full of errors when I load Best HTTP in a empty project so i really hope you can adres this issue im on a Mac with 4.5 Pro

    The warnings are

    There are inconsistent line endings in the 'Assets/Best HTTP (Pro)/Examples/LitJson/JsonData.cs' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.

    Script 'Tree' has the same name as built-in Unity component.
    AddComponent and GetComponent will not work with this script.

    There are inconsistent line endings in the 'Assets/Best HTTP (Pro)/Examples/LitJson/IJsonWrapper.cs' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.




    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'.
    at (wrapper managed-to-native) System.MonoType:GetMethodsByName (string,System.Reflection.BindingFlags,bool,System.Type)
    at System.MonoType.GetMethods (BindingFlags bindingAttr) [0x00000] in <filename unknown>:0
    at Mono.CSharp.MemberCache.AddMethods (BindingFlags bf, System.Type type) [0x00000] in <filename unknown>:0
    at Mono.CSharp.MemberCache.AddMethods (System.Type type) [0x00000] in <filename unknown>:0
    at Mono.CSharp.MemberCache..ctor (IMemberContainer container) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeHandle..ctor (System.Type type) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeHandle.GetTypeHandle (System.Type t) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeHandle.GetMemberCache (System.Type t) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, MemberTypes mt, BindingFlags bf, System.String name, System.Boolean& used_cache) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeManager.RealMemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TypeManager.MemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.MemberLookup (Mono.CSharp.CompilerContext ctx, System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.MemberLookup (Mono.CSharp.CompilerContext ctx, System.Type container_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.ResolveUserOperator (Mono.CSharp.ResolveContext ec, System.Type l, System.Type r) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.ResolveOperator (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.DoResolveCore (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression left_orig, Mono.CSharp.Expression right_orig) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Binary.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Expression.ResolveBoolean (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression e, Location loc) [0x00000] in <filename unknown>:0
    at Mono.CSharp.If.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TryCatch.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.TryFinally.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
    at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.FlowBranching parent, Mono.CSharp.BlockContext rc, Mono.CSharp.ParametersCompiled ip, IMethodData md) [0x00000] in <filename unknown>:0
     
  30. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi DNArt.

    You have to move the Plugins folder(from /Assets/Best HTTP (Pro)/) to your (root) /Assets/ folder.
    After this step, you also should restart Unity to let it pick the right dll.
     
  31. DNArt

    DNArt

    Joined:
    Jan 16, 2014
    Posts:
    21
    Hi Best HTTP

    You are so right that solved all !!!
    Thanks !!
     
  32. MatthieuMichalet

    MatthieuMichalet

    Joined:
    Jan 30, 2014
    Posts:
    6
    Hello,

    I start to use BestHttp asset few days ago and I have some questions :

    - I saw there is no timeout to kill a request if it take too long time. Is there other tricks to stop a request already launch ?
    - I use callbacks to add an OnFinishedFunction and I have similar problems with a simple request which take 3-5 sec normaly and sometimes the request can take 30-60 sec and one time the request has no finished 5 min after be launched.

    Any solutions please ? =)
     
  33. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi MatthieuMichalet.

    1.) Sorry, I can't give you any tip to cancel a request.
    2.) It should be outside of the plugin as BestHTTP dispatches every request as soon as possible. But if you can make a repro project I will take a look on it.
     
  34. MatthieuMichalet

    MatthieuMichalet

    Joined:
    Jan 30, 2014
    Posts:
    6
    Ok thank you for your answer.
    I can show you a part of my code but it's really simple, i call AskLog by a GUI.Button :

    private string _url = "http://myurl.com/myfile.php"
    private string _result = "";
    private int _lengthDownload = 0;
    private int _downloaded = 0;

    private void AskLog()
    {
    HTTPRequest request = new HTTPRequest(new Uri(_url), OnAskLogFinished);
    request.OnProgress = OnDownloadProgress;
    request.Send();
    }

    private void OnAskLogFinished(HTTPRequest request, HTTPResponse response)
    {
    if (response != null)
    {
    _result = response.DataAsText;
    }
    else
    {
    _result = "RESPONSE NULL";
    }
    }

    private void OnDownloadProgress(HTTPRequest request, int downloaded, int length)
    {
    _downloaded = downloaded;
    _lengthDownload = length;
    }

    And with that, the callback OnAskLogFinished is called between 5 and 60 sec or never. This code is based upon your examples
    Any idea ?
     
  35. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    I use this code to test the download progress feature (formatted to the forum):
    Code (CSharp):
    1. string progressStr = string.Empty;
    2. void ProgressTest()
    3. {
    4.     var request = new HTTPRequest(new Uri(address),
    5.                                     HTTPMethods.Get,
    6.                                     /*isKeepAlive:*/ false,
    7.                                     /*disableCache:*/ true,
    8.                                     /*callback:*/ (req, resp) =>
    9.     {
    10.         Debug.Log(progressStr);
    11.  
    12.         Debug.Log(resp.DataAsText);
    13.     });
    14.     request.OnProgress = (req, downloaded, length) =>
    15.         progressStr += "Progress: " + downloaded + " / " + length + " " +
    16.                         (downloaded / (float)length * 100).ToString("F2") + "%\n";
    17.  
    18.     progressStr = string.Empty;
    19.     request.Send();
    20. }
    And it's working pretty fine for me.
    The address that i use to test are an image from wikipedia(~12.5 MB), the html of the RFC6265 and a Unity setup exe(~1 GB).

    Can you send me in email your url that you want to use? Maybe i can figure it out whats going on.
     
  36. MatthieuMichalet

    MatthieuMichalet

    Joined:
    Jan 30, 2014
    Posts:
    6
    I don't think my problem is linked to my url. I have an unstable connexion with my devices and i try to fix this bug.
    I tried some codes which didn't resolve my problems :
    - request.DisableRetry = true; => didn't work
    - take yours parameters of HTTPRequest => didn't work
    - Launch coroutine to change the callback OnFinished => didn't work because I have an error when i change the request.Callback

    With the last test, I do this after my timeout :

    Code (CSharp):
    1.         if (request.Response == null)
    2.         {
    3.             request.Callback -= OnAskLogFinished;
    4.             request.Callback += FunctionOnTimeOut;
    5.         }
    6.  
    The function FunctionOnTimeOut was called but the function OnAskLogFinished was also called !
    I should change the callback not correctly, but i don't find how to do it properly ?
     
  37. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    To ignore responses that you consider outdated i would do something like this:

    Code (CSharp):
    1. var request = new HTTPRequest(new Uri(address),
    2.                                 HTTPMethods.Get,
    3.                                 (req, resp) =>
    4. {
    5.     DateTime started = (DateTime)req.Tag;
    6.     if (DateTime.UtcNow - started > TimeSpan.FromSeconds(30))
    7.         return;
    8.  
    9.     // Request finished in time
    10. });
    11.  
    12. request.Tag = DateTime.UtcNow;
    13. request.Send();
    This way the callback will be called, but ignored if the given time is passed.
     
    Nickolauson likes this.
  38. MatthieuMichalet

    MatthieuMichalet

    Joined:
    Jan 30, 2014
    Posts:
    6
    Oh thanks ! I like this ! =)
    But "lost requests" can't block others request in process ?
     
  39. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    It will if reaches it's maximum request per server (4 by default), but you can increase it with HTTPManager.MaxConnectionPerServer:
    Code (CSharp):
    1. HTTPManager.MaxConnectionPerServer = 255;
     
  40. MatthieuMichalet

    MatthieuMichalet

    Joined:
    Jan 30, 2014
    Posts:
    6
    Ok ok,
    And one last question, there is no ways to clear all connexions ?

    Otherwise, thanks for all ! I will come back if I find some other problems.
    =)
     
  41. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    No, as they are still in-progress. They will processed as usual just without any effect in your case.
     
  42. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    207
    I saw that it was on your possible features list, but how is the progress on aborting a request?
     
  43. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Currently struggling with the WSA support, and doing bugfixes and little improvements in the meantime. After that i have to rewrite a good part of the code to be able to abort the process in a good way.

    So not anytime soon.
     
  44. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    207
    Shucks, alright. Does that mean there's no way to do a timeout? Say if a call takes 30 seconds, it should just give up.
     
  45. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Nop. You can do some hacks to ignore timeouted requests, but nothing reliable now.

    (Writing this post just came to my mind an idea. I will try it out, maybe it will be a good and working solution.)
     
  46. illuminat

    illuminat

    Joined:
    Jul 2, 2014
    Posts:
    40
    Hi there,

    I just bought your plugin... But if i import it i get the following error:

    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
    Im using unity 4.51f3 free.


    thanks for help

     
  47. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Hi illuminat.

    Please make sure that you moved the Plugin folder to your root /Assets/ folder. And you should restart the editor too.
     
  48. illuminat

    illuminat

    Joined:
    Jul 2, 2014
    Posts:
    40
    oh didn't read that in the readme. thanks, it works.
    is it possible to use fiddler as a proxy?
     
    Last edited: Jul 2, 2014
  49. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,433
    Yes, you can set up a request for Fiddler like this:
    Code (CSharp):
    1. var request = new HTTPRequest(new Uri("https://www.google.com"), (req, resp) => Debug.Log("Connected through proxy!"));
    2. request.Proxy = new HTTPProxy(new Uri("http://localhost:3128"));
    3. request.Proxy.IsTransparent = true;
    4. request.Send();
     
  50. illuminat

    illuminat

    Joined:
    Jul 2, 2014
    Posts:
    40
    thanks!
     
unityunity