Problem with 1.2.4

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Problem with 1.2.4

Postby Molix » 23 Nov 2009, 20:24

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]
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 24 Nov 2009, 07:55

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
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Postby Molix » 24 Nov 2009, 13:54

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.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 24 Nov 2009, 14:01

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
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Postby Molix » 24 Nov 2009, 14:11

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).
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 24 Nov 2009, 14:24

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
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Postby Molix » 24 Nov 2009, 14:36

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.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 24 Nov 2009, 14:38

OK - will take it from here. Thanks for doing a few quick tests!!

/Thomas
ringhino
Posts: 8
Joined: 19 Dec 2008, 08:33

Postby ringhino » 14 Dec 2009, 11:20

Hi Thomas... any news about this fix? we have the same problem with 1.2.4

thanks
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Postby Molix » 04 May 2010, 17:17

Any ETA on the next version, which hopefully will have this fix in it?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 04 May 2010, 17:50

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
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 04 May 2010, 20:03

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
Last edited by ThomasLund on 04 May 2010, 20:34, edited 1 time in total.
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Postby Molix » 04 May 2010, 20:32

Confirmed fix (on Mac with Firefox, Unity 2.6.1, SFS 1.6.6, API 1.2.4).

Thanks Thomas!
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Postby Molix » 04 May 2010, 20:35

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();
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 04 May 2010, 20:38

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

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 1 guest