Page 1 of 1

Can't Login to Zone with Java

Posted: 30 Dec 2008, 16:16
by crtjer
I have attempted to create a Java client that connects to SFS server. I used the tutorial to connect to the server and that works fine however connecting to a zone doesn't seem to work. In my onConnection handler, I call the login method to the zone. After this it seems to hang. Any ideas? Thanks a lot.

Posted: 30 Dec 2008, 19:37
by crtjer
Continuing on and debugging more. I found out that I send out complete xml string but I receive a broken xml string back from the server. Any ideas? Thank you very much.[/quote]

Posted: 31 Dec 2008, 10:37
by Lapo
What version of the server is being used?
Can you show the code that doesn't work?
Finally the XML coming back should not be broken. Where do you see that is malformed? Can you show what you get back exactly?

Happy new year :)

p.s. = I have moved this in the BETA API section, it's more appropriate

Posted: 09 Jan 2009, 22:08
by crtjer

Code: Select all

01-05 14:13:02.534: VERBOSE/SMARTFOXAPP(197): onConnection listener set up.
01-05 14:13:02.534: VERBOSE/SMARTFOXAPP(197): onJoinRoom listener set up.
01-05 14:13:02.534: VERBOSE/SMARTFOXAPP(197): onRoomListUpdate listener set up.
01-05 14:13:02.713: VERBOSE/SMARTFOXAPP(197): [Sending]:<msg t ='sys'><body action='verChk' r='0'><ver v='154' /></body></msg>
01-05 14:13:02.752: VERBOSE/SMARTFOX(197): [RECEIVED]: <cross-domain-policy><allow-access-from domain='*' to-ports='9339' /></cross-domain-policy>, (len: 91)
01-05 14:13:02.893: INFO/ActivityManager(49): Displayed activity 1179 ms
01-05 14:13:02.944: INFO/global(197): Jan 5, 2009 2:13:02 PM <init>
01-05 14:13:02.944: INFO/global(197): INFO: Default buffer size used in BufferedReader constructor. It would be better to be explicit if a 8k-char buffer is required.
01-05 14:13:03.002: VERBOSE/SMARTFOX(197): [RECEIVED]: , (len: 0)

I'm trying to connect to a SmartFoxPro Server.

Posted: 10 Jan 2009, 15:19
by Lapo
what kind of application is this? Are you using our beta Java API?
Those logs don't look very familiar to me. Additionally from what I can see the XML you are receiving is correct.

Please give us more details on the problem.

Posted: 11 Jan 2009, 01:27
by crtjer
I am using the Java Beta API and I'm using this under Android. The Debug you see is the SmartFoxServer debug statements just using the Android logger. I'm using the sample code from the Java Beta API rar that is provided. As I was debugging it seems like XMLSocket isn't connecting properly. This is just through debugging it step by step. Thanks for you help.

Posted: 12 Jan 2009, 07:18
by Lapo
I am sorry, unfortunately the Java API are not currently tested under Android.
As far as I know Google's platform supports a large selection of the Java2SE framework but I am not sure of the limitations.
The XMLSocket library used in the API contain the core socket classes which use java.nio behind the scenes. I guess there could be compatibility problems between at that level.

We'll take a look when we have time and see if we can provide a wrapper or an alternative socket library that works correctly under Android.

Thanks for reporting

Posted: 12 Jan 2009, 18:39
by crtjer
Is there anyway I can be given the source for the XMLSocket.jar so I can investigate and possibly create a fix for it? Thank you very much for your responses.

Posted: 13 Jan 2009, 07:07
by Lapo
The problem is unlikely to be there, as the XMLSocket library is based on xsocket which is the socket library being used.

I've given another look that log you have posted I am still clueless about what the problem is, exactly.
You seem to be able to establish a connection and receive a couple of messages from the server correctly.
This means that most of the core stuff is actually working pretty well, otherwise you wouldn't be able to even start a connection.

Can you say where the BufferedReader warning is coming from? Is it your code instantiating that object?
As far as I can remember the SFS API code shouldn't use any of those unless it's coming from the socket library.
Also, after you receive an empty message you don't seem to be sending any other requests... what is exactly going on after that?
Is there more to that log data?

Posted: 19 Jan 2009, 17:23
by Lapo
I have an update on this.
We have an alternative version of XMLSocket library which uses Apache Mina instead of the XSocket library.

XSocket seems to refer to Java RMI which is not supported by Android.
If you want to try the Mina-based API drop us an email and we'll send the jars. It won't require any changes in your code, just replacing the references to the external libraries in your IDE

Hope it helps :)

Posted: 20 Jan 2009, 07:55
by Lapo
One more update:
I can confirm that the Mina-based XMLSocket library works flawlessly under Android. Tested with the latest Android SDK available as of Jan 20th 2009

Hope it helps

Posted: 26 Oct 2009, 14:22
by promore
if you want to toggle the ONLOGIN event you must set the server/config.xml the zone tags's attribute customLogin = true
then you can handle event in your client !
I hope it can help you!
Friend from China! :lol: