Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Best HTTP Released

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

  1. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    If you want a plugin that supports request customization for REST, WebSocket, Socket.IO, SignalR, SignalR Core, Server-Sent Events (and much more) over HTTP/2 out of the box, with regular updates and outstanding support from the developer, then BestHTTP/2 is THE tool for you!


    You can try out the package on its own demo page and read the online documentation.

    All source code included!

    Supported platforms:
    - WebGL
    - iOS, Android
    - UWP, Windows, Mac OS X, Linux

    Most notable features are:
    - HTTP/2
    - Customize all parts of your requests:
       ◦ Methods(GET, HEAD, POST, PUT, DELETE, PATCH)
       ◦ Headers
       ◦ Cookies
       ◦ Max redirect count
       ◦ Timeouts
    - Access every bits sent by the server:
      ◦ Headers
      ◦ Status code
      ◦ Cookies
      ◦ Raw content
      ◦ Trailing headers
    - Connection and memory pooling
    - Connection and request timeouts
    - Automatic Cookie handling
    - Great range of Proxy support (Fiddler, Charles, etc.)
    - HTTP and Socks Proxy support
    - Automatic caching and cache validatation
    - Set your cache size and freshness
    - gzip content encoding
    - Basic and Digest authentication
    - Multiple form types (url-encoded and multipart/form-data)
    - Automatic redirection handling
    - Upload and Download progress tracking
    - Access your data while downloading
    - You can resume downloads using Range headers
    - HTTPS
    - Customize a great range of global settings:
      ◦ Max connection per server
      ◦ Enable/disable cookies
      ◦ Private 'Browsing'
      ◦ Cookie Jar size
      ◦ etc

    WebSocket features:
    - Full RFC compliance
    - Easy to use, 'just works' experience
    - Support for extensions:
      ◦ Compression Extensions for WebSocket (RFC7692)

    Socket.IO features:
    - Compliance with the latest (1.x and 2.x) Socket.IO implementations
    - Automatic <strong>transport upgrade</strong> and downgrade
    - <strong>Binary data</strong> sending and receiving
    - You can plug in your favorite Json decoder

    SignalR Core features:
    - Supports latest SignalR Core
    - Strongly typed callbacks
    - Uses the fastest Websocket transport
    - Package includes a Header-based authenticator
    - Upload and download streaming


    SignalR features:
    - Works with the latest SignalR implementation
    - Easy to use API
    - Hubs
    - Support for authentication
    - Progress messages for long running jobs
    - Automatic transport upgrade/downgrade
    - You can plug in your favorite Json decoder

    Server-Sent Events features:
    - Compatible with the latest specification
    - Easy to use API

    Useful links:
    - Documentation
    - Samples repository
    - Server repository
    - Twitter
    - LinkedIn

    For support, feature request or general questions you can email me at besthttp@gmail.com.
     
    Last edited: Nov 7, 2019
    umcherrel likes this.
  2. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
    got demo apk on the streaming?
     
  3. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi imtrobin.

    You can download the demo apk here, and you can check the code directly here.
    The interesting codes are located in the StartDownload and in the OnfragmentDownloaded functions.

    If you have any more questions feel free to ask here or at the besthttp@gmail.com email address.
     
    Last edited: Sep 15, 2013
  4. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
    The DownloadStreamingTestScene only plays audio? It loads fine and I hear music and when it pause, I press Play again and it crashes.
     
  5. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi imtrobin,

    That's a strange behavior, I never seen that.
    And yes, it's only plays audio, but i should remind you, it's not a production ready audio streaming code so there might be bugs and - as you experienced - crashes.
    The main purpose was to demonstrate the streaming capabilities of the plugin.

    I will try to reproduce that crash, but I'm very confident that it's not occurred in the HTTP plugin rather than in the demo code.

    Edit: Streaming audio was my only idea to demonstrate streaming using a http plugin somehow spectacularly. Downloading a file and displaying only a download indicator is boring. :)
    But if someone can suggest me a good idea that is good for a little demo, that would be welcome.
     
    Last edited: Sep 16, 2013
  6. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
    streaming video would be good. after all, that's the purpose of what we want to stream.
     
  7. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Yes video streaming would be better, but making a crossplatform video streaming demo would produce more obfuscated demo code, and i think the current audio streaming sample is already too complex for a lightweight demonstration.
    The MovieTexture is desktop (and i think webplayer) only. The Handheld.PlayFullScreenMovie is iOS and Android only. And I'm curious about the Windows Phone 8 support, as I'm supporting this new mobile platform too.
    Plus i don't know how these would react when they need to play from an incomplete file, as they can play only from a file or from an url(this case that would be a very bad streaming demo:)).
    In a real product there should be (native) plugins to handle the video playing per platform, but for just a demo that would be too much work.
     
  8. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
  9. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Well, i agree but streaming video is just one thing, the main point behind streaming is getting data before the download ends.
    • So streaming can be used for downloading larger files and resume the download if your app closed or disconnected from the internet. (Write out to disk the downloaded fragments and resume with a Range request.)
    • Or you can start processing the response for a long-polling request.
    • You can start download (a maybe larger) leaderboard and show players that already downloaded. The response can be cached on the user's device and next time this cached response can be used if the leaderboard doesn't changed.
      This can be done with a simple request. You don't need to write code to handle the caching and validation of the cache. You just need a simple download request and set up the server to send back last-modified or eTag headers and handle the cache validation.
      This way you achive better user experience, spare user and server bandwith and spare processing power on the server too.

    So while i agree that when streaming is read the first thing to come in mind is video, but with a little creativity it can be very useful in other areas too.
    And now with my plugin it can be easy too. ;)
     
  10. dede_touchten

    dede_touchten

    Joined:
    Jul 11, 2012
    Posts:
    6
    Hi, Before I buy this plugin, I just want to confirm if Best HTTP can do the following:
    • Use REST API with PUT method
    • Use REST API with DELETE method
    • Modify / add HTTP headers (just like in curl -H)
    • Change HTTP request Content-Type
    • Add HTTP POST Data (just like in curl -d)
    • Compatible with Unity 3.5.x
    • Socket.IO compatibility
    • I have an assumption that basic version will supports all the Pro features when it is released, just minus the source code?
    Thanks!
     
  11. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi avatech,

    Thank you for you interest!

    These are all supported right now.

    Unity 3.5.7 support is waiting for approval in the Asset Store, should be out this week.

    Scoket.IO is not supported now.

    Yes, your assumptions are right.

    I hope you will find the best tool for your needs!
     
  12. dede_touchten

    dede_touchten

    Joined:
    Jul 11, 2012
    Posts:
    6
    Wow, thanks for the fast reply. I'll buy this as soon as the 3.5.7 support is up!
     
  13. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi avatech,

    Thank you for your patience.

    I'm happy to announce that Best HTTP Pro is live, and the update for the Basic edition is out too.
    They both supports Unity 3.5.7.
     
  14. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    These are stuck in my head, so i added another demo scene to the collection: LeaderboardTest. The android demo updated too.
    The server side is a little Ruby code using the Sinatra framework:
    Code (csharp):
    1. get '/LeaderboardTest/:from/:count' do |f, c|
    2.     from = f.to_i
    3.     count = c.to_i
    4.  
    5.     # Set 'Expires' header to the current Time + 1 minute
    6.     headers 'Expires' => (Time.now + 60).utc.httpdate.to_s
    7.  
    8.     # Create the leaderboard stream and write out 10 player
    9.     stream do |out|
    10.         count.to_i.times do |pos|
    11.             out << "Player_Name_#{(from + pos).to_s};#{(from + count - pos) * 100}\n"
    12.  
    13.             # Here is the streaming magic. :)
    14.             sleep 0.5
    15.         end
    16.     end
    17. end
    If you open the leaderboard url there is a high chance that your browser will display the result only when all data downloaded.
    In the demo app, the leaderboard will display continuously the received players. The result will be cached, and used while it's not expires(1 min).
     
  15. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Yesterday i started to read the specification of the Basic and Digest authentication.
    The Basic is already done.
    I hope i will finish before the end of the week and i can send the update to the Asset Store.

    And if i finish these very quickly, maybe the proxy authentication will be in this update too.
     
  16. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Both type of authentication done now. Setting up a request to use authentication can be done by one easy step: setting it's Credentials property.
    An example can be seen here:
    Code (csharp):
    1. var request = new HTTPRequest(new Uri("https://httpbin.org/digest-auth/auth-int/user/passwd"), (req, resp) =>
    2.         {
    3.             if (resp.StatusCode != 401)
    4.                 Debug.Log("Authenticated");
    5.             else
    6.                 Debug.Log("NOT Authenticated");
    7.         });
    8.  
    9. request.Credentials = new Credentials("user", "passwd");
    10. request.Send();
    For proxy authentication i need to set up a proxy server to test my code, but otherwise its should be ok too.
    Last week's update still pending in the asset store, but should be out in the next one or two days, after that i will submit this update to the asset store.
     
  17. Gundoglu

    Gundoglu

    Joined:
    Sep 26, 2013
    Posts:
    2
    Bought the plugin a few days ago and it's working great.

    In our next project, however, we need to use websockets.
    I saw in the documentation that you're planning to add support for it. My question is, that when this feature will be available? Are you planning to release it in the near future?
     
  18. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi Gundoglu,

    Thank you for your kind words.

    Regarding the WebSocket support: I will start to implement it in the coming weeks, so when you will start to develop your next game it will be ready for you. :)
     
  19. Gundoglu

    Gundoglu

    Joined:
    Sep 26, 2013
    Posts:
    2
    Hey, thanks for the fast answer.

    We're still just planning what to use so you definitely have a few more weeks to add this. :)
     
  20. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    New update uploaded to the Asset Store, will be out next week:
    • [New Feature] Basic and Digest authentication support through a new Credentials property in the HTTPRequest class
    • [Improvement] More then one redirection supported for a single request
    • [Improvement] New MaxRedirects property in the HTTPRequest class
    • [Improvement] New GetFirstHeaderValue(string headerName) function in the HTTPRequest class
    • [Improvement] New optimized parsers, for now only used for parsing the authentication header
    • [Improvement] Some code cleanup
    • [Bugfix] In some cases after sending the request and not receiving any data caused a new reconnect
    • [Bugfix] Some caching proxies return with float values in Max-Age header

    A quick sample how you can use the new authentication:
    Code (csharp):
    1. var request = new HTTPRequest(new Uri("https://httpbin.org/digest-auth/auth-int/username/password"), (req, resp) =>
    2. {
    3.   if (resp.StatusCode != 401)
    4.     Debug.Log("Authentication successful");
    5.   else
    6.     Debug.Log("Authentication Failed");
    7.  
    8.   Debug.Log(resp.DataAsText);
    9. });
    10.  
    11. request.Credentials = new Credentials("username", "password");
    12. request.Send();
     
  21. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    206
    So I've been using UniWeb recently, and they had an issue where all my requests were occurring twice for some reason even though I was definitely only calling it once. Any time I would do a POST through UniWeb, it would create two entries. However, if I used Unity's WWW class, it would work properly. So it's not an issue on our server end. Also the creator doesn't appear to be responding to anything.
    Does BestHTTP do something similar with sending multiple requests?
     
  22. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi,

    I didn't know any issue like this about my plugin, but I'm always here to help and fix any bug if there is any.
     
  23. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    206
    I appreciate the insanely quick reply. I will probably purchase this within the next few minutes just because of that, haha.
     
  24. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Thank you,

    If you will find any issue, need help or you have some suggestion, don't hesitate to drop me a mail.
     
  25. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    206
    Not sure if it's stated anywhere, but what level of stripping am I allowed to use?
     
  26. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Didn't checked the stripping levels yet, but i definitely will later today.

    However Unity love to strip out the whole System.Security namespace so without a link.xml it should be a problem.
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi KamiKaze425,

    I was able to build run the demos with all stripping level without any additional work.
     
  28. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    206
    That's fine. I already need System.Security for a cryptography thing, so I have that link.xml file. I was just making sure I could use all the stripping levels, and it appears to work fine.
    I recommend putting that in your description, it would be a major selling point.
     
  29. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Thank you for the tip.
     
    Last edited: Oct 9, 2013
  30. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi Gundoglu!

    Just wanted to let you know that I finished adding the WebSocket support to BestHTTP, currently writing the documentation.
    I hope it will be out at the end of the week.
     
  31. apprenticegc

    apprenticegc

    Joined:
    Apr 21, 2012
    Posts:
    7
    I just bought Best HTTP Pro from asset store minutes ago. But when it is imported into a blank project, I saw the error. I am using Mac Book with OS 10.9 and Unity 4.2.2f1 Pro. I try to adjust the build setting "Api Compatibility Level", neither ".Net 2.0" nor ".Net 2.0 Subset" make the error disappear. And I have been restarted Unity each time I adjust the setting. Please help.

    $Screen Shot 2013-11-08 at 2.18.43 PM.png
     
  32. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi apprenticegc,

    You need to move the Plugins folder from the Best Http Pro folder to your Assets folder.

    (This is becouse assets can be uploaded to the store only when they are in one folder. But unity loads plugins from the Assets/Plugins folder only. So this is a limitation of unity, but i hope you understand this, and I'm sorry for any inconvenience.)
     
    Last edited: Nov 8, 2013
  33. apprenticegc

    apprenticegc

    Joined:
    Apr 21, 2012
    Posts:
    7
    Thanks, the problem is solved. Don't notice the difference the location of "Plugins" folder matters. I usually put my DLLs anywhere in "Plugins" folder(s) and they do work fine. I guess there must be some rule to "Plugins", "Editor" and "Resources" which I don't quite understand. I will spend some time to research on this topic later. But anyway, thanks for replying me so quickly.
     
  34. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    WebSocket support is live now in both Basic and Pro versions.
     
  35. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    324
    I am trying to use version 1.2 with unity 4.3.0f4 but importing the package from asset store causes a internal compiler error. I am importing it to an empty project. I have Unity pro/iOS pro /Android pro The exact error is

    ---
    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
     
  36. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi Ryuuguu,

    You need to move the Plugins folder from the Best Http folder to your Assets folder.

    This is because assets can be uploaded to the store only when they are in one folder. But unity loads plugins from the Assets/Plugins folder only. So this is a limitation of unity, but i hope you understand this, and I'm sorry for any inconvenience.
     
  37. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    324
    Thank you for quick reply. I even knew about this I just forgot when installing.
     
  38. chirhotec

    chirhotec

    Joined:
    Mar 30, 2010
    Posts:
    47
    I'm trying to post to a https url, but whenever I do, I get a null response and the request has an exception.

    Relevant code:

    And the exception:


    Any ideas on what might be causing this problem? I saw the documentation used https examples. I'm following it pretty closely, but I didn't see anything in there that indicated I needed to do something special to send https requests.

    Right now I'm just running from within the Unity Editor, but I plan to run it from iOS, Android, and hopefully WebPlayer.
     
    Last edited: Nov 20, 2013
  39. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi chirhotec.

    Of course https is fully supported on all platforms.
    In this case its looks like the server is sending wrong data or a non https stream.
    On platforms that you listed the plugin uses mono's own implementation so i think something should be wrong on server side, but if you send to me a "working" code sample that i can test, maybe i can figure out more about this problem.
    (All private urls that i get i use them only for debugging and i delete them as soon as they are not needed any more, or i can reproduce the problem in an other way.)

    I hope we will find out a solution quickly.

     
  40. bcole_pxlplz

    bcole_pxlplz

    Joined:
    Nov 20, 2013
    Posts:
    5
    I'm having a bit of a problem getting the Websocket events hooked up with C#.
    My Code looks like this:
    Code (csharp):
    1.  
    2. private WebSocket ws;
    3.  
    4. public ConnectionManager () {
    5.  
    6.         ws = new WebSocket(new System.Uri("http://localhost:8080"));
    7.        
    8.         ws.OnOpen += this.OnWebSocketOpen;
    9.         ws.OnMessage += this.OnMessageReceived;
    10.        
    11.         ws.Open();
    12. }
    13.  
    14. private void OnWebSocketOpen(WebSocket webSocket) {
    15.     Debug.Log("I opened a web socket!");
    16. }
    17.  
    18. private void OnMessageReceived(WebSocket webSocket, string message) {
    19.     Debug.Log("Message Recieved");
    20. }
    Neither the OnWebSocketOpen and OnMessageRecieved events are not being called. I can see the initial connection being sent to the server. I feel like I must have the delegates set up incorrectly, but I'm not sure why. Could someone point me in the right direction?
     
  41. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Hi bcole_pxlplz

    There are an event that called when an error occurs, that should tell us more about what went wrong:

    Code (csharp):
    1.     ws.OnError += OnWebSocketError;
    2.  
    3.     private void OnWebSocketError(WebSocket ws, Exception ex)
    4.     {
    5.         if (ws.InternalRequest.Response != null)
    6.             Debug.LogError("Status: " + ws.InternalRequest.Response.StatusCode + " " + ws.InternalRequest.Response.Message);
    7.  
    8.         if (ex != null)
    9.             Debug.LogError(ex.ToString() + "\n\r" + ex.Message + "\n\r" + ex.StackTrace);
    10.     }
     
  42. bcole_pxlplz

    bcole_pxlplz

    Joined:
    Nov 20, 2013
    Posts:
    5
    When I instantiate WebSocket with
    Code (csharp):
    1.  new WebSocket(new System.Uri("wss://localhost:8080"));
    I get a:
    System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
    from OnWebSocketError.

    When I instantiate WebSocket with
    Code (csharp):
    1.  new WebSocket(new System.Uri("http://localhost:8080"));
    None of the delegates are called.

    I can't use wss as a protocol unfortunately (my socket server is written in php, using ratchet). Do you have any suggestions?

    edit:
    I do have the "pro" version, so I can make some changes to the WebSocket class if need be.
     
  43. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Can you try with
    Code (csharp):
    1. new WebSocket(new System.Uri("ws://localhost:8080"));
    The System.IO.IOException: The authentication or decryption has failed message thrown because ws is for the normal protocol and wss for the secure one(as http and https). On your localhost the web server is serving a non secure connection while the client trying to connect to it as a secure one("wss").

    Anyway, i will check out this Ratchet to see whether there is a problem with my implementation.
     
    Last edited: Nov 20, 2013
  44. chirhotec

    chirhotec

    Joined:
    Mar 30, 2010
    Posts:
    47
    I sent you a private message with a link to a unitypackage with the relevant files. But now my Sent Box isn't showing it. Please let me know if I should send it again.
     
  45. bcole_pxlplz

    bcole_pxlplz

    Joined:
    Nov 20, 2013
    Posts:
    5
    I tried again with new WebSocket(new System.Uri("ws://localhost:8080")) and I'm back to not getting an exception, but again, none of the delegates are being called.

    I logged the messages out of my server, and I'm getting
    Connection 28 sent message 'GET / HTTP/1.1'
    Connection 28 sent message 'Host: '
    Connection 28 sent message 'localhostUpgrade: websocketConnection: keep-alive, UpgradeSec-WebSocket-Key: gHwJqgCss33wNjO4AJtX1w==Sec-WebSocket-Version: '
    Connection 28 sent message '13Cache-Control: no-cachePragma: no-cacheAccept-Encoding: gzip, deflate, identity'
    Connection 28 sent message 'TE: chunked, identity'
    Connection 28 sent message ''


    which to me looks correct. Is the client waiting on a 'connection success' message sent from the server?
     
  46. bcole_pxlplz

    bcole_pxlplz

    Joined:
    Nov 20, 2013
    Posts:
    5
    Edit: Oops, thought chirhotec was replying to me.
     
    Last edited: Nov 20, 2013
  47. chirhotec

    chirhotec

    Joined:
    Mar 30, 2010
    Posts:
    47
    Sorry, that was for BestHTTP, from the previous page :)
     
  48. bcole_pxlplz

    bcole_pxlplz

    Joined:
    Nov 20, 2013
    Posts:
    5
    Nope, it was me. I figured out what was going on. To anyone using Ratchet: Make sure your webserver instance includes the IoServer, HttpServer, and WsServer.
     
  49. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Please try to resend it, it get lost somewhere in the wires. :)
     
  50. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,368
    Im happy that is working now.