Page 1 of 2

Problem with 1.2.4

Posted: 23 Nov 2009, 20:24
by Molix
I just noticed an issue with the change from 1.2.3 to 1.2.4. I don't understand what it is, but hopefully you will.

Repro:
Build your Unity game with 1.2.4.
Open your game in Firefox (Mac).
Close the window/tab (Cmd+W), but do not quit Firefox.
Open your game in Firefox again.

Result:
Failure to connect to SFS. The SFS server shows assertions (below).

Workaround:
Quit Firefox (Cmd+Q) before opening your game.

Notes:
Rebuilding with 1.2.3 works as expected.

I hope that helps (I really want 1.2.4! :) Let me know if I can send any other info.


Assertions:


Code: Select all

INFO   | jvm 2    | 2009/11/23 15:21:15 | java.net.ConnectException: Connection refused: connect
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at sun.nio.ch.Net.connect(Native Method)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:81)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:65)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.xsocket.stream.io.impl.IoProvider.openSocket(IoProvider.java:346)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.xsocket.stream.io.impl.IoProvider.createClientIoHandler(IoProvider.java:209)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.xsocket.stream.Connection.<init>(Connection.java:160)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.xsocket.stream.NonBlockingConnection.<init>(NonBlockingConnection.java:394)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.xsocket.stream.NonBlockingConnection.<init>(NonBlockingConnection.java:209)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at it.gotoandplay.utils.net.xmlsocket.XMLSocket.connect(XMLSocket.java:54)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at it.gotoandplay.smartfoxserver.httpbox.util.SFSHandshake.<init>(SFSHandshake.java:29)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at

it.gotoandplay.smartfoxserver.httpbox.filter.SessionIDFilter.doFilter(SessionIDFilter.java:114)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:387)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at

org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.Server.handle(Server.java:324)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:451)
INFO   | jvm 2    | 2009/11/23 15:21:15 | Invalid connection = null
INFO   | jvm 2    | 2009/11/23 15:21:15 | java.lang.NullPointerException
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at it.gotoandplay.utils.net.xmlsocket.XMLSocket.send(XMLSocket.java:93)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at it.gotoandplay.smartfoxserver.httpbox.util.SFSHandshake.<init>(SFSHandshake.java:30)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at

it.gotoandplay.smartfoxserver.httpbox.filter.SessionIDFilter.doFilter(SessionIDFilter.java:114)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:387)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at

org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.Server.handle(Server.java:324)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
INFO   | jvm 2    | 2009/11/23 15:21:15 |    at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:451)
[/code]

Posted: 24 Nov 2009, 07:55
by ThomasLund
I'll take a look at this asap tonight. I only did very minor changes to the networking (ability to use hostnames instead of ip) and thats more or less it.

If you are online before then, could you please poke me with the player.log from the webplayer (on the Mac thats in Library/Logs/Unity or something similar)?

Also what version Firefox and Unity?

Thanks and sorry for any problems.

Best
Thomas

Posted: 24 Nov 2009, 13:54
by Molix
This is from the player.log; it looks like your suspicions were correct:

Code: Select all

System.Net.Sockets.SocketException: No such host is known
  at System.Net.Dns.GetHostByAddressFromString (System.String address, Boolean parse) [0x00000]
  at System.Net.Dns.GetHostEntry (System.Net.IPAddress address) [0x00000]
  at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000]
  at LoginGUI.DoConnect () [0x00000]
UnityEngine.Debug:Log(Object)
LoginGUI:DoConnect()
LoginGUI:Awake()
 
(Filename: /Users/build/builds/unity-26/unity-2.6.x/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1783)


As for Unity, I'm still using 2.5 (2.5.1f5).
Firefox is 3.5.5.

Thanks for the quick reply.

Posted: 24 Nov 2009, 14:01
by ThomasLund
Hi again,

Seems like that yeah!

Could I get you to test it with 2.6 if possible? If it works in PC, Mac, iPhone and not in web, then I might have to roll in a switch or revert - or require 2.6

I got a game running made with 2.5 for PC, Mac, iPhone (v. 1.5) where there is no problem with hostnames. But no webgame.

Good question - but lets crack the nut.

/Thomas

Posted: 24 Nov 2009, 14:11
by Molix
A couple other things:
    - it works fine on the PC webplayer (also in Firefox)
    - I'm not even looking up a hostname--it is an IP address--so those exceptions may be a red herring--the ones that matter are on the server (first post). I'll see if there is something else going on.


Switching to 2.6 will be non-trivial (we have a team of people and it isn't backward compatible).

Posted: 24 Nov 2009, 14:24
by ThomasLund
Right - it looks like I might have introduced the exception by removing the parsing of the string IP.

Firefox on Mac is notoriously bad at handling exceptions - any exception will put it on its back. Been there, done that when I first made the API.

Regarding 2.6 - was mostly if you had the possibility.

Quick test in your end - try to use a hostname as a workaround? I'll try to get on it later today on finding a solution that works for both IP and hostname.

/Thomas

Posted: 24 Nov 2009, 14:36
by Molix
If I use a hostname, it works the first time (resolves the IP, and connects), but the second time it fails to resolve the hostname, which leads to "I/O Error: An invalid IP address was specified." when connecting.

Posted: 24 Nov 2009, 14:38
by ThomasLund
OK - will take it from here. Thanks for doing a few quick tests!!

/Thomas

Posted: 14 Dec 2009, 11:20
by ringhino
Hi Thomas... any news about this fix? we have the same problem with 1.2.4

thanks

Posted: 04 May 2010, 17:17
by Molix
Any ETA on the next version, which hopefully will have this fix in it?

Posted: 04 May 2010, 17:50
by ThomasLund
Just a quick comment to all. I've been super busy with lots of things - amongst others you might have seen SFS 2x announcement.

Anyways - I'll get a look at this tonight, so to get this out of the way. I got a good idea of what the issue could be.

If I find it, I'll post it asap as a manual source code fix. Then lets see when busy Marco has a chance to repackage things

Sorry for waiting for this.

/Thomas

Posted: 04 May 2010, 20:03
by ThomasLund
OK - good news and bad news.

The good news - I found the problem. Bad news - its not something I can fix without removing the new 1.2.4 feature of being able to use hostnames instead of only IP addresses.

The trouble comes from this line in the ConnectThread method in SmartFoxClient.cs:

Code: Select all

socketConnection.Connect(ipAddress, port);


If you use this instead, then it works (at least here):

Code: Select all

IPAddress parsedIpAddress = IPAddress.Parse(ipAddress);
socketConnection.Connect(parsedIpAddress, port);
//socketConnection.Connect(ipAddress, port);


Could one of you please try this in your project and confirm the issue?

This seems solely to be related to the Unity webplayer plugin. Looking up hostnames seems to work fine in C# and stand alone Unity builds (which is what I use for my own games).

This is tested with Unity 2.6.1 and SFS 1.6.6 server using 1.2.4 API source code.

The big deal here is, that you typically dont want to hardcode IPs into your apps if you can get away with it. Using hostnames you can move your servers around + you can do hostname DNS load balancing via round robin in most DNS servers to take off peak load. Damn.

Another edit:
This turns out to be a bug in Mono that has existed in Unity for ages. Too bad its not fixed yet (meaning its fixed in Mono - but not in the version of Mono that Unity ships with).

/Thomas

Posted: 04 May 2010, 20:32
by Molix
Confirmed fix (on Mac with Firefox, Unity 2.6.1, SFS 1.6.6, API 1.2.4).

Thanks Thomas!

Posted: 04 May 2010, 20:35
by Molix
Btw, I've been doing the following for DNS. It has been working, but is it incorrect?

Code: Select all

System.Net.IPHostEntry ip = System.Net.Dns.GetHostEntry( serverIP );
Debug.Log( "Resolved " + serverIP + " to " + ip.AddressList[0] );
serverIP = ip.AddressList[0].ToString();

Posted: 04 May 2010, 20:38
by ThomasLund
OK - thanks for confirming.

The big question now being - can you live with having to fix this yourself in the sources?

I'd have to hack up the sources badly with some Unity defines and stuff to see if it can be made, so the webplayer can only use IP adresses - and the rest can use hostnames. Something I would rather take a clean look at later than right now (for various reasons).

I'd hate to end up with a Unity only API + a generic C# one + a Silverlight one if at all possible :-)

(And make that double with the new SFS 2x stuff).

/Thomas