Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What proxy server can we use?

Discussion in 'Multiplayer' started by MikeHergaarden, Aug 24, 2009.

  1. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    I want to experiment using a proxy server to solve (web)game connection problems. Luckily unity provides us with the option. However, what proxy server can we run?

    I tried installing squid on Centos, and verified that this http proxy worked. I couldn't start a multiplayer server using this proxy though. I set the right port and IP but squid didn't even log any connection. Unity complained about not being able to start the server due to being unable to reach the proxy.

    Did anyone successfully set up a proxy yet? What setup works?
     
  2. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    The same problem. Browser proxy settings not affect to WWW class requests in web-player.

    It seems that even http://www.fusionfall.com/ (biggest unity3d on-line game) do not solve this problem (friezes on start load asset bundles).

    This problem happens when web Browser set-up to use some special proxy server like proxy.example.org:3128.

    It is great problem, cause many peoples connects to Internet through the non transparent proxy servers.

    P.S. I duno which way WWW class uses the Browser API, when it work with cache, but not work with proxy at same time.
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    has anyone of you ever tested if the Network.proxyxxxx settings have any impact on the proxy behavior of WWW? Or if they are purely related to Unitys multiplayer capability.
     
  4. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Nope, since I haven't even be able to use a proxy for the unity networking itself
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Nope to get it to work or nope to the WWW part?

    Just to clarify that: Unity is not interested in your systems proxy config, you would have to tell it to use the proxy and enter the proxy details in the corresponding Network.xxx fields.
     
  6. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181

    Thx! But this try was not success, I mean this:

    Code (csharp):
    1.  
    2. Network.proxyIP = "192.168.0.1";
    3. Network.proxyPort = 3128;
    4.  
    I think as logical that position: "If you are work as web player, you by default use browser API for make requests, and you do not know proxy or other things like this". This is not exclude that class may have non-default tuning.

    Any other ideas? Office workers of all world, waiting for our web games :) They all usually behind a proxy, its luck if it transparent.

    P.S. Sorry for may Russian-English, I hope my opinion is clear.
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Well its a game technology, not a browser, so I don't see why it should use configs that are meant for a browser, especially as not all proxys offer UDP due to the massive missuse of proxys for P2P.


    Are you sure that you didn't mess the IP and really wanted to use your local lan router as your proxy?
    Additional things:
    1. is the proxy without password?
    2. did you set useProxy, otherwise proxy configs are ignored

    for more, please see http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=network

    and last but not least. did you test if the unity networking works or did you only test WWW?

    Potentially above will set the System.NET proxy to the same as you set the network (which is raknet, not System.NET based), but if not you could also set it through the corresponding system net end and test it.
    See here: http://www.hccp.org/csharp-http-proxy.html
     
  8. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    >Well its a game technology, not a browser, so I
    >don't see why it should use configs that are meant
    >for a browser,

    I think webplayer is not so complex as web browser, so no needs to poor emulate web browser functions if exists ability for browser API using. This needs only for standalone games.

    In other words, if webplayer have web browser as parent object, so it may to use browser methods, as it usual in OPP style .


    >Are you sure that you didn't mess the IP and
    >really wanted to use your local lan router as your
    >proxy?

    We was try to use local and global address (on other machine with global IP). My Linux router is my proxy (Squid), no mistake there.

    >Additional things:
    >1. is the proxy without password?

    No. But I have this kind of proxy to, and was try to use it.

    >2. did you set useProxy, otherwise proxy configs
    >are ignored

    Yes I do.

    >for more, please see http://unity3d.com/support
    >/documentation/ScriptReference
    >/30_search.html?q=network
    >and last but not least. did you test if the unity
    >networking works or did you only test WWW?

    Do not test networking, I think there nothing to test. WWW class works perfectly without proxy, this tested on several computers.

    >Potentially above will set the System.NET proxy to
    >the same as you set the network (which is raknet,
    >not System.NET based), but if not you could also
    >set it through the corresponding system net end
    >and test it.

    >See here: http://www.hccp.org/csharp-
    >http-proxy.html[/quote]

    thx immediately!

    Actualy, my the script is:

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6. using System.Text;
    7. using System.Net;
    8.  
    9. void Awake()
    10.     {
    11.  
    12. //global proxy ip
    13.     Network.proxyIP = "77.66.145.184";
    14.     Network.proxyPort = 3128;
    15.     Network.useProxy = true;
    16.  
    17. /*
    18. // other example behind the NAT
    19. Network.natFacilitatorIP = "192.168.0.1";
    20. Network.natFacilitatorPort = 3128;
    21. Network.useNat = true;
    22. */
    23.  
    24. /*
    25.  
    26. //or for proxy with user/password behind the NAT
    27. System.Uri proxyURI = new System.Uri("http://192.168.0.1:3128");
    28.   System.Net.WebProxy proxy = new System.Net.WebProxy(proxyURI);
    29.   proxy.Credentials = new System.Net.NetworkCredential("USER", "PASSWORD");
    30.   WebRequest.DefaultWebProxy = proxy;
    31.  
    32. */
    33.  
    34.     }
    35.  
    36.  
    37. void start(){
    38.  
    39.    WWW w = new WWW("http://www.kembl.ru");
    40.  
    41. }
    42.  
    43.  
    and then i seek for activity in the squid access log files.
     
  9. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    So this one works or thats the script you had for testing that didn't work?
     
  10. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    No, no one works. Just error

    Code (csharp):
    1.  
    2. You are trying to load data from a www stream which had the following error when downloading.
    3. couldn't connect to host
    4. UnityEngine.WWW:get_texture()
    5. UnityEngine.WWW:get_texture()
    6. <>c__CompilerGenerated2:MoveNext() (at Assets\Network\CNetObjectsLoad.cs:103)
    7.  
    8. [..\..\Runtime\Export\[url]WWW.cpp[/url] line 652]
    9.  
    The proxy host is reachable. May be this mean, that destination point not reachable, but in squid access logs nothing appear to.

    May be exists some kind of undocumented method like

    www.bytes = 0x1231261253561a266d6127f...

    We need only assetbundle download ability, so we can get it like bytes with other technique, and then load bytes in to WWW class.

    Other idea. Load bundles through javascript (so browser works it self), but how to interoperate between two *.unity3d files on page? By javascript? It is slow method (i think, but not tested yet), or may be we can set direct link between resources in two webplayers on one page?
     
  11. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you can not interporate between to unity3d files. you can only load one at a time, loading the other removes the first.

    Question is how many are affected by proxys? because at least here in europe the only ones behind proxys are those who are not meant (and often not capable) to play games anyway.
     
  12. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    I mean load it by call external javascript with parameter in to different html frame/div, and then interoperate, may be through serialisation, this is only idea.

    I hope problem is not so big: biggest percent of proxies are transparent and not a problem.

    But this interest question it self, I think 20% office workers surf on Internet in Europe/USA, and may be 3-4% of it looking for games. It is much more than several millions.

    We are Russian oriented, and Russia have no such big numbers (only 20 million peoples (all ~146 mil.) have Internet), but i think one or two millions of peoples, waste its time in internet from offices, and as usual in Russia, they have corporate proxies, which allows only WEB connections.


    Plus home networks, for several owners with one router.

    I think the proxy using problem have one more important side. When you have big web project, proxy allows to decrease main web servers cluster loading, increase access speed and decrease servers farm traffic prices (if they exists). So if you can pay several days work time for try to solve this problem, this activity can save hardware loading and money in future. If you open this technology for others, you will help to save world traffic and time globally. 8)
     
  13. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    So, did your proxy setup actually work for the regular unity networking?

    Using your IP/port here didn't work for me. Furthermore I'm still not sure what proxy server I should setup that I can use. Squid doesn't seem to work since it's not a UDP proxy(?). RakNet's UDPProxy example project didn't seem to work either.

    Has anyone actually got the unity proxy feature working? If so; what proxy server are you using?
     
  14. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    Why do you need UDP proxy?
    The main, unique thing in WWW class that it works with AssetBundles. No way handle that with out this class. If your program do not needs to load AssetBundles, you can use direct connection to Proxy IP:port, see:

    This is example of direct request to the site

    http://forum.unity3d.com/posting.php?mode=reply&t=30852

    Code (csharp):
    1.  
    2. GET /posting.php?mode=reply&t=30852 HTTP/1.0
    3. Host: forum.unity3d.com
    4. Accept-Language: ru,en-us;q=0.7,en;q=0.3
    5. Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
    6.  
    7.  
    after request, site answer with page content.

    And this is request to PROXY IP:port

    Code (csharp):
    1.  
    2. GET [url]http://forum.unity3d.com/posting.php?mode=reply&t=30852[/url] HTTP/1.0
    3. Host: forum.unity3d.com
    4. Accept-Language: ru,en-us;q=0.7,en;q=0.3
    5. Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
    6. Keep-Alive: 300
    7. Proxy-Connection: keep-alive
    8.  
    9.  
    Main difference in first string, all other not so important, after request, proxy return page content.

    So you can construct proper headers and directly talk with proxy.

    If you wish to build game network for cooperative game between gamer behind the NAT and gamers in outer world, the simplest way to do this - router port mapping (setup by hand ) or uPNP (actually not know how) (www.upnpworks.alcidelic.com/links.html) (www.whitebear.ch) (http://miniupnp.free.fr/). More complex way to combine gamers - lobby or game server.
     
  15. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    I'm trying to get the unity proxy (Network.useProxy etc.) working for the unity networking: Network.Connect, RPC's and so on. And I don't know if it's UDP or not (just guessing so) but I need to know what proxy server works.
     
  16. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    For solve the protocol question needs to start server with some port (7777 for example) , I mean

    Code (csharp):
    1.  
    2. Network.InitializeServer(32, 7777);
    3.  
    and check with netstat command, which kind of port has LISTEN status: TCP or UDP.

    netstat example (without any unity server):
    Code (csharp):
    1.  
    2. [root@wserver1 home]# netstat -an
    3. Active Internet connections (servers and established)
    4. Proto Recv-Q Send-Q Local Address               Foreign Address             State
    5. tcp        0      0 127.0.0.1:199               0.0.0.0:*                   LISTEN
    6. tcp        0      0 0.0.0.0:619                 0.0.0.0:*                   LISTEN
    7. tcp        0      0 0.0.0.0:10733             0.0.0.0:*                   LISTEN
    8. tcp        0      0 :::2000                     :::*                        LISTEN
    9. tcp        0      0 :::80                       :::*                        LISTEN
    10. ...
    11.  
    this is from Centos, but with windows / mac you'll get the same results.
     
  17. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    277
    Hopefully I can clear a bit of confusion up. The WWW class, .NET WebProxy class used by System.Net.WebRequest and then the proxy setting for the inbuilt networking are all separate entities and do not affect one another. I.e. setting Network.useProxy does not affect the WWW class.

    The WWW class uses the browser when running in the webplayer plugin and it should use whatever proxy setting the browser has. Testing this is of course only possible in an actual webplayer as the editor/standalones use different code.

    The inbuilt networking Network.useProxy uses a separate proxy server which is available for download (yes it is UDP based like the whole networking layer). Contact me directly through email or PM to get it (I'll send you a PM Leepo). I'll make sure a download link for it is made publicly visible as soon as possible (seems to have disappeared).
     
  18. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    Thx for useful answers!

    >Testing this is of course only
    >possible in an actual webplayer as the
    >editor/standalones use different code.

    This is a "root of evil".

    Looks good, but for completely solution we need to answer only two questions:

    1) Which method to use WWW with proxy from Editor (for more fast code checks)? Is this theoretical possible?

    2) Which method to define where app working (on web browser or in editor and, I think that I saw solution on forum) for select when use 1) (from editor) and when not (from webapp).