Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UniWeb

Discussion in 'Assets and Asset Store' started by simonwittber, May 23, 2013.

  1. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Last edited: Jul 11, 2014
    twobob likes this.
  2. redsky

    redsky

    Joined:
    May 23, 2013
    Posts:
    5
    Hi! I have worked with unitWeb for one year and everything was fine! But after last update I have the following errors:
    HTTP error unknown url :Server closed the connection:System.IO.IOException: Read failure ---> System.Net.Sockets.SocketException: Operation timed out.
    at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags flags) [0x00000] in <filename unknown>:0
    at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
    --- End of inner exception stack trace ---
    at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
    at System.IO.Stream.ReadByte () [0x00007]
    This errors rise in HTTP GET and POST requests
     
    Last edited: May 23, 2013
  3. redsky

    redsky

    Joined:
    May 23, 2013
    Posts:
    5
    I recover the old version and everything work fine.
     
  4. aikitect

    aikitect

    Joined:
    Dec 28, 2012
    Posts:
    28
    I am using UniWeb and UniParse on iOS, and I am getting the following error:

    ystem.Net.Sockets.SocketException: No such host is known
    at System.Net.Dns.hostent_to_IPHostEntry (System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) [0x00000] in <filename unknown>:0
    at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in <filename unknown>:0
    at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000] in <filename unknown>:0
    at System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress) [0x00000] in <filename unknown>:0
    at System.Net.Sockets.TcpClient.Connect (System.String hostname, Int32 port) [0x00000] in <filename unknown>:0
    at HTTP.Request.GetClient (System.String host, Int32 port, Boolean useSsl) [0x00110] in /Users/Dennis/Dev/EasyEater/Assets/UniWeb/Plugins/Request.cs:186
    at HTTP.Request.<Send>m__F (System.Object t) [0x0010a] in /Users/Dennis/Dev/EasyEater/Assets/UniWeb/Plugins/Request.cs:265
     
  5. Eric-Laberge

    Eric-Laberge

    Joined:
    Jan 20, 2011
    Posts:
    26
    Hello!

    I'm trying to test an iOS app with a tablet configured to use an HTTP proxy, but it seems to ignore the settings. Default Unity WWW class and other web app (Safari) seem to work.

    I suppose there's some stuff missing in UniWeb that's causing the proxy settings to be ignored.

    For specifics, I'm testing HTTPS security with my app using mitmproxy.
     
  6. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    Does this support cookies?
     
  7. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    hi there
    do you support unity on win8 and windows phone 8?
     
  8. younity

    younity

    Joined:
    Aug 18, 2012
    Posts:
    15
    Hi there, what settings are needed for HTTPS?
     
  9. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    support here doesn't look very good.. Posts over a week old with no reply.
     
  10. MacSecrest

    MacSecrest

    Joined:
    Oct 31, 2012
    Posts:
    6
    To anyone else needing support I recommend downloading "JetBrains dotPeak" which lets you decompile the DLL to find what you need.

    I was going to purchase this but I found it on GCode for free. If there is support for Unity 3.5 I would buy it.


    Here's the Link: https://code.google.com/p/unityweb/
     
    Last edited: May 30, 2013
  11. Murdock

    Murdock

    Joined:
    May 21, 2013
    Posts:
    5
    Hi, can this plugin be used to connect to the Facebook Graph API?
     
  12. MacSecrest

    MacSecrest

    Joined:
    Oct 31, 2012
    Posts:
    6
    Check that the referenced filename is formatted correctly. I get that error when the directories don't exist or when the filename is invalid.
     
  13. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Thanks for reporting the proxy problem, I will look into this.

    Cookies are supported, using the .NET cookie classes.
     
  14. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    I'm not sure on the specifics of the Graph API, however if it is just HTTP then UniWeb can help with that.
     
  15. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Decompiling is not needed, when you buy UniWeb you get the source code. Please be aware the GCode version is based on a very old version of UniWeb.
     
  16. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Not directly, as I don't have those platforms, however UniWeb should work wherever Unity works!
     
  17. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    No extra settings are needed, just use "https://" in the URL.
     
  18. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    The "No such host is known" error seems to indicate that the URL you are attempting to use does not resolve via DNS?
     
  19. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    I'm having a problem implementing this. I've emailed yesterday and no one responded. Anywho, I'm trying to post a form and then get the results but the response.text is a diamond with a "?" In it (unprintable character of some kind). I'm probably doing something wrong but your examples don't fully show how its done.
     
  20. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Email received, but haven't had time to respond.

    I suspect this is related to a unicode issue which I am in the middle of fixing. In the meantime, you can read the Bytes value instead, and decode it using System.Text.Encoding.UTFEncoding or something similar.
     
  21. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    i can decode it using all diferent encoding.. still getting that weird diamond question mark
     
  22. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    i changed the way i am doing it and now i have something different. now i am getting this from the server:


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <HTML><HEAD><TITLE>Length Required</TITLE>
    <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
    <BODY><h2>Length Required</h2>
    <hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
    </BODY></HTML>
     
  23. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Is there anything in the Bytes array? Does it have a length > 0?
     
  24. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    ok, i found out more information... if i have this:

    w.AddField("d", "EAAAAGMkLIvqpak4jPw4h34Y3Bst1d pq5pe1EFd B1Dh10QE/m2FDwkw8DRHdzrbKczjpdZJVDywJsSyqAzIxDuZf2Z7wnC8QkUGJ1rYU1m6DQvBmwdPbW0oHPmTotRNBdUlQ==");

    then i get the <?>..

    without it, i get the message above (about the length required).

    btw, i am sending encrypted messages to/from the server for an MMO..
     
  25. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    when i get the <?> the response.Bytes.Length=1341
     
  26. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    in case it helps, the server side is ASP MVC 4 running on IISExpress..
     
  27. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
  28. Murdock

    Murdock

    Joined:
    May 21, 2013
    Posts:
    5
    Hi Simon, thanks for your answer, the reason I ask about support for the Graph API is because I'm trying to connect to it and I'm getting this error on the web player:

    Code (csharp):
    1. System.Security.SecurityException: Unable to connect, as no valid crossdomain policy was found
    2.   at System.Net.Sockets.Socket.Connect_internal (IntPtr sock, System.Net.SocketAddress sa, System.Int32 error, Boolean requireSocketPolicyFile) [0x00000] in <filename unknown>:0
    3.   at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in <filename unknown>:0
    4.   at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
    5.   at System.Net.Sockets.TcpClient.Connect (System.Net.IPEndPoint remote_end_point) [0x00000] in <filename unknown>:0
    6.   at System.Net.Sockets.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, Int32 port) [0x00000] in <filename unknown>:0
    This is the code I'm using:

    Code (csharp):
    1. IEnumerator  GetUserInfoUniWeb()
    2. {
    3.     var request = new HTTP.Request("GET", "https://graph.facebook.com/100002347686605?fields=id,name,friends&access_token=" + accessToken);
    4.  
    5.     request.Send();
    6.  
    7.     while(!request.isDone) yield return new WaitForEndOfFrame();
    8.  
    9.     if(request.exception != null)
    10.     {
    11.            Debug.LogError(request.exception);
    12.     }
    13.     else
    14.     {
    15.            var response = request.response;
    16.            Debug.Log(response.status);
    17.        Debug.Log(response.GetHeader("Content-Type"));
    18.        Debug.Log(response.Text);
    19.     }
    20. }
    The same code works fine on iOS. The example also works on the web player if I use WWW instead of UniWeb.
    In the examples says you need to call PrefetchSocketPolicy in order to this to work on the web player, but in my case it doesn't makes any difference.

    I'm missing something?

    Thanks!
     
  29. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
  30. Murdock

    Murdock

    Joined:
    May 21, 2013
    Posts:
    5
    Ok, I guess then that you can't connect to a third party server(like facebook) using sockets if they don't have a policy server running, which seems to be the case with Facebook:

    When I connect to my own server(which is running the socket policy server provided with Unity), I get this

    Code (csharp):
    1. iMac:~ murdock$ telnet 172.16.48.128 843
    2. Trying 172.16.48.128...
    3. Connected to cgwks419.comp.local.
    4. Escape character is '^]'.
    5. <policy-file-request/>
    6. <?xml version="1.0"?>
    7. <cross-domain-policy>
    8.    <allow-access-from domain="*" to-ports="1200-1220"/>
    9. </cross-domain-policy>"Connection closed by foreign host.
    But when I try to fetch the policy file from facebook I get this:

    Code (csharp):
    1. iMac:~ murdock$ telnet graph.facebook.com 843
    2. Trying 31.13.85.16...
    3. Connected to star.c10r.facebook.com.
    4. Escape character is '^]'.
    5. <policy-file-request/>
    6. Connection closed by foreign host.
    I guess I'm stuck with WWW for facebook. I'm still will be using UniWeb to communicate with the game api on my own servers.

    Thanks for your help.
     
  31. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    @Murdock

    Are you saying that there is some kind of support for the policy server on graph.facebook.com, or is it something random running on port 843?
     
  32. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    FYI: A new version (1.9.21) is uploading do Asset Store for review now, which should address recently discovered issues. Feedback appreciated!
     
  33. luccafortino

    luccafortino

    Joined:
    Jun 7, 2013
    Posts:
    1
    Hi there,
    I'm facing an issue when trying to update a field in a database. (using ParseInstance.Update())

    Sometimes I can update the value with no problem, but sometimes, apparently if I wait a couple of minutes before sending another update request, I get an error: "HTTP Exception unterminated stream".

    I'm I missing something?

    Thanks in advance
     
  34. aikitect

    aikitect

    Joined:
    Dec 28, 2012
    Posts:
    28
    How do you catch this type of exception? I am using UniParse and it tells me I can't put a yield in a try-catch statement. It effectively causes a crash in my iOS app if I have no internet connection instead of failing gracefully...
     
    Last edited: Jun 8, 2013
  35. lordzizzy

    lordzizzy

    Joined:
    Jan 17, 2012
    Posts:
    2
    Hi, just to clear things up: does uniweb support Unity Android? I read in the Unity licence comparison page that they do not support .NET sockets in the non-Pro version. Thanks in advance!
     
  36. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    This bug was fixed recently, are you using the latest version?
     
  37. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    UniWeb requires .NET sockets. If these are not available on your platform, UniWeb will not work. Apart from this issue, there is no known problems when using UniWeb on an Android platform with .NET sockets.
     
  38. demid

    demid

    Joined:
    Mar 20, 2012
    Posts:
    9
    Hi! I'm getting a strange error while running HTTPS requests to my server from Android device:
    Mono.Security.Protocol.Tls.TlsException: Couldn't complete EndRead
    at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
    at System.Net.Security.SslStream.EndRead (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
    at System.Net.Security.SslStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
    at System.IO.Stream.ReadByte () [0x00000] in <filename unknown>:0
    at HTTP.Response.ReadLine (System.IO.Stream stream) [0x00000] in <filename unknown>:0
    at HTTP.Response.ReadFromStream (System.IO.Stream inputStream) [0x00000] in <filename unknown>:0
    at HTTP.Request.<Send>m__55 (System.Object ) [0x00000] in <filename unknown>:0

    In the editor this requests sequence works good. The exception is strange because it happens during a 1-2Kb request after a successfull series of short (with body <1Kb) requests to the same server. What the reason could be? Google says nothing interesting on this exception message :(

    EDIT: Response size is comparable to request size in my scenario (<1Kb request => <1Kb response, >1Kb request => >1Kb response), so maybe the problem is related somehow with response size rather than request size. One more thing to add: I've checked http logs of my web server and all hung requests seem to be the client side problem because time-taken value is 1 sec max in all cases.

    EDIT2: The Android client fails to read even a single byte, even a response code from the server.
     
    Last edited: Jun 12, 2013
  39. Davide1104

    Davide1104

    Joined:
    Jun 12, 2013
    Posts:
    38
    Hi,
    I want know if is possible done this:
    run a server socket on the desktop of OSX
    and allow a user with iPhone's Safari browser to connect via wifi to the
    soket local Mac server that go back to a web page That interacts with the server socket on a mac

    I do not know if I was clear

    my question is to know if this module you can create a this interaction

    Thanks
     
  40. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    I have a suspicion that this might be caused by the Keep-Alive connection pooling. If you comment out #USE_KEEPALIVE at the top of Request.cs, does the problem still occur?
     
  41. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    It sounds like you want to create a web server within Unity3D? If so, UniWeb does not do this, it is a client library only.
     
  42. demid

    demid

    Joined:
    Mar 20, 2012
    Posts:
    9
    This was one of the first things I've done while experimenting. I have to add that I tried read/write timeouts for the TcpClient and SslStream with no luck. When I looked at the SslStream's method causing the exception I was really upset:

    Code (csharp):
    1.  
    2. public override int EndRead(IAsyncResult asyncResult)
    3. {
    4.     this.checkDisposed();
    5.     InternalAsyncResult result = asyncResult as InternalAsyncResult;
    6.     if (result == null)
    7.     {
    8.         throw new ArgumentNullException("asyncResult is null or was not obtained by calling BeginRead.");
    9.     }
    10.     if (!asyncResult.IsCompleted  !asyncResult.AsyncWaitHandle.WaitOne(0x493e0, false))
    11.     {
    12.         throw new TlsException(AlertDescription.InternalError, "Couldn't complete EndRead");
    13.     }
    14.     if (result.CompletedWithError)
    15.     {
    16.         throw result.AsyncException;
    17.     }
    18.     return result.BytesRead;
    19. }
    20.  
    You may notice a hardcoded timeout of 5 minutes in asyncResult.AsyncWaitHandle.WaitOne(0x493e0, false) :(
     
  43. Davide1104

    Davide1104

    Joined:
    Jun 12, 2013
    Posts:
    38
    ok

    thanks for the reply
     
  44. Jiraboas

    Jiraboas

    Joined:
    Nov 16, 2012
    Posts:
    13
    I had an issue with UniWeb:

    Do a simple get request on a RESTful server(vuforia vws api), but i do not get a response if i used coroutines:

    Code (csharp):
    1.    
    2.  
    3. //create http get request
    4. HTTP.Request getRequest = new HTTP.Request("GET",url);
    5.        
    6. //send request and wait for response
    7. getRequest.Send();
    8.        
    9. //wait for response, corroutine dont work(why?)
    10. while(!request.isDone) yield return new WaitForEndOfFrame();
    11.        
    12. if(getRequest.exception != null)
    13. {
    14.   Debug.LogError(getRequest.exception);
    15. }
    16. else
    17. {
    18.   HTTP.Response response = getRequest.response;
    19.   //inspect response code
    20.   Debug.Log(response.status);
    21.   //inspect headers
    22.   Debug.Log(response.headers.Get("Content-Type"));
    23.   Debug.Log("Response from server: " + response.Text);
    24. }
    This code doesnt work for me. If i replace:

    Code (csharp):
    1. while(!request.isDone) yield return new WaitForEndOfFrame();
    with:

    Code (csharp):
    1. while(!request.isDone)
    2. {
    3.    //empty
    4. }
    5.  
    The programm does, what i has expected.

    The UniWebExample does work WITH the "yield return null" line, but not my own code.

    The full url of my request is: https://vws.vuforia.com/targets

    Are there any problems with the server i have to fix?

    Thanks for your help!

    -Jira
     
  45. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Is this an editor script, or a game script?
     
  46. Jiraboas

    Jiraboas

    Joined:
    Nov 16, 2012
    Posts:
    13
    It is a gamescript, but after everything worked i have planed to use these functions(upload, update, and so on) within the unity editor.

    -Jira

    EDIT: Got another problem with UniWeb. I do a put request on the vws-server(i have done this before but have to use UniWeb because of mac issues), but the server returns "AuthenticationFailure". It is the same code like before, and if i change "PUT" with "GET" everything is working. But if i use PUT, i get an error from the server. Any ideas why it doesnt worked with UniWeb?

    As i said, I used the HTTPRequest-class before and everything worked, but since i use UniWeb, my put request is rejected by the server...

    EDIT2: Tested all other needed methods: GET, POST, DELETE, everything else worked...

    EDIT3: Ok, dont know why, but now it worked. But i dont find any solution for the coroutine-problem!
     
    Last edited: Jun 14, 2013
  47. itjunkii

    itjunkii

    Joined:
    Dec 1, 2011
    Posts:
    35
    Hi Simon,

    Thank you for making this! Using Parse is vital to my new app so I am really happy.

    I purchased Uniweb and after I put my keys in to UniParse I got these three errors:

    401
    UnityEngine.Debug:Log(Object)
    <Start>c__Iterator0:MoveNext() (at Assets/Plugins/UniParse/Demo/UniParseTest.cs:18)

    An error occured, likely a bad password!
    UnityEngine.Debug:Log(Object)
    <Start>c__Iterator0:MoveNext() (at Assets/Plugins/UniParse/Demo/UniParseTest.cs:26)


    ArgumentNullException: Argument cannot be null.
    Parameter name: s
    System.DateTime.Parse (System.String s, IFormatProvider provider, DateTimeStyles styles) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System/DateTime.cs:918)
    System.DateTime.Parse (System.String s, IFormatProvider provider) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System/DateTime.cs:912)
    System.DateTime.Parse (System.String s) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System/DateTime.cs:907)
    ParseInstance.get_createdAt () (at Assets/Plugins/UniParse/Plugins/ParseClass.cs:204)
    UniParseTest+<Start>c__Iterator0.MoveNext () (at Assets/Plugins/UniParse/Demo/UniParseTest.cs:47)


    Any ideas what I did wrong?

    Thanks again!
     
  48. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    I'm going to need see more code to see what is wrong. The coroutine support is quite fundamental to UniWeb, what are you doing that is different from the usage in the examples?
     
  49. bardic

    bardic

    Joined:
    Feb 8, 2012
    Posts:
    10
    Stupid question but I'm gonna ask it anyway. Can I use this when building from mac with the free version of unity for ios and android?
     
  50. itjunkii

    itjunkii

    Joined:
    Dec 1, 2011
    Posts:
    35
    Hello, I sent a previous post saying that your out-of-the-box demo code does not work with Parse. I paid the money specifically so it would work with Parse. Can you help me? Are you willing to help me?

    Otherwise I will ask for a refund.