Problem getting examples to work

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

sinax
Posts: 8
Joined: 22 Oct 2018, 18:11

Problem getting examples to work

Postby sinax » 22 Oct 2018, 18:38

Hey guys,

I'm pretty new to this environment and may have done some things wrong or missed some steps so please help me take my first steps.

I already installed SmartFoxServer 2x v 2.13 and then updated it to v 2.13.3. The server is up and running. I connected to the admin panel.

Then I wanted to give the provided HTML5-JS examples as I'm planning to use this platform from my web app game. I downloaded and extracted the examples' files and started to try out with the most basic one, `Connector`.

In the server panel, I wen to Server `Configurator -> Web Server` and turned on `Enable WS/WSS` switch.

The web page loaded successfully but the connection did not go right. I got the following messages:
Connecting...
Disconnection occurred; reason is: unknown


There is no connection log in the admin panel. I have no idea how to go forward and make it work.

More environment info:

    Both server and client are run on localhost
    I didn't change any other server config
    The client version is 1.7.11

Any help or suggestion would be appreciated.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem getting examples to work

Postby Lapo » 22 Oct 2018, 19:14

Hi,
sounds like you have done all the correct steps.
Have you changed any other settings? Maybe in the Zone configuration?

Also are you running client and server on the same machine?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
sinax
Posts: 8
Joined: 22 Oct 2018, 18:11

Re: Problem getting examples to work

Postby sinax » 23 Oct 2018, 07:04

Thank you Lapo for the quick reply.

No I didn't mess up with other settings as long as I recall. BTW is there any safe way to reset all server settings and start over?

I also wonder how to get detailed connection log on tge sever side?
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem getting examples to work

Postby Lapo » 23 Oct 2018, 07:55

A couple more questions/suggestions.

1) Did you restart SFS2X after enabling WS/WSS? It is required.
2) Are you testing from the local filesystem? In other words by dragging the example's index onto the browser? If so that might cause connection issues due to security/origin issues. Chrome can complain about it, while Firefox usually doesn't.

You could try with Firefox or deploy the example under the SFS2X/www/root/<example-name> folder and then open the example by pointing the browser to http://localhost:8080/<example-name>/

No I didn't mess up with other settings as long as I recall. BTW is there any safe way to reset all server settings and start over?

You will have install another copy of the server. Though I don't think it's necessary, if you've just tinkered with a couple of settings.

I also wonder how to get detailed connection log on tge sever side?

You will get error messages about connection issues on the server side if the client connection makes it to the server :)
In this case it looks like the connection did not even reach the server at all.

By the way, what OS are you using?
Let us know
Lapo

--

gotoAndPlay()

...addicted to flash games
sinax
Posts: 8
Joined: 22 Oct 2018, 18:11

Re: Problem getting examples to work

Postby sinax » 23 Oct 2018, 08:18

1) Did you restart SFS2X after enabling WS/WSS? It is required.

Yes I did, using windows Services console I did Stop and Start `sfs2x-service` .

2) Are you testing from the local filesystem? In other words by dragging the example's index onto the browser? If so that might cause connection issues due to security/origin issues. Chrome can complain about it, while Firefox usually doesn't.

I was testing through the internal web server, using the following url:

Code: Select all

http://localhost:8080/examples/Html5/Connector/


You will get error messages about connection issues on the server side if the client connection makes it to the server :)
In this case it looks like the connection did not even reach the server at all.


You're right. It seems there's no connection made. Though I think the initial WS connection can establish as I get the following connection in Chrome developer tools:

Code: Select all

Request URL: ws://localhost:8080/BlueBox/websocket
Status Code: 101 Switching Protocols


By the way, what OS are you using?

I'm using Windows 10 Pro, Version 1803, OS Build 17134.345

Thanks for your kind help
sinax
Posts: 8
Joined: 22 Oct 2018, 18:11

Re: Problem getting examples to work

Postby sinax » 23 Oct 2018, 08:39

I also tried the "AdvancedChat" example and got the following logs in the console:

Code: Select all

Application started
sfs2x-api-1.7.11.js:6 [ SFS2X | INFO ] SmartFox instance ready
sfs2x-api-1.7.11.js:6 [ SFS2X | INFO ] SFS2X JavaScript API v1.7.11
sfs2x-api-1.7.11.js:6 [ SFS2X | INFO ] Attempting connection to server
sfs2x-api-1.7.11.js:6 [ SFS2X | DEBUG ] Socket connection established
sfs2x-api-1.7.11.js:6 [ SFS2X | INFO ] Sending request 'Handshake' to server
sfs2x-api-1.7.11.js:6 [ SFS2X | DEBUG ] OUTGOING MESSAGE: Handshake (0)

   (utf_string) api: 1.7.11
   (utf_string) cl: JavaScript
   

sfs2x-api-1.7.11.js:6 [ SFS2X | DEBUG ] DATA WRITTEN - Binary size: 54
80 00 33 12 00 03 00 01 63 02 00 00 01 61 03 00    ..3.....c....a..
00 00 01 70 12 00 02 00 03 61 70 69 08 00 06 31    ...p.....api...1
2E 37 2E 31 31 00 02 63 6C 08 00 0A 4A 61 76 61    .7.11..cl...Java
53 63 72 69 70 74                                  Script         

sfs2x-api-1.7.11.js:6 [ SFS2X | DEBUG ] Socket disconnection occurred


Thought it might help the troubleshooting.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem getting examples to work

Postby Lapo » 23 Oct 2018, 08:47

Can you also show me what the server side reports in the logs when the client connects and is kicked out right after?
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
sinax
Posts: 8
Joined: 22 Oct 2018, 18:11

Re: Problem getting examples to work

Postby sinax » 23 Oct 2018, 08:59

I could not find any log entry showing the connection.
You can see get all logs here:
https://drive.google.com/file/d/19YWsY-5DnW5Ufzkd6RZc9es5HI9oZiA3/view?usp=sharing
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem getting examples to work

Postby Lapo » 23 Oct 2018, 09:07

It looks like you are using mismatching protocols.
You've probably accidentally switched the binary protocol off from the webserver panel.

Via the AdminTool > Server Settings > Web Server make sure that Use WS binary protocol is active.
Restart and try again.

In any case when there's a protocol mismatch you should see an error on the server side such as this:
Websocket request rejected. Received: Byte[], Required: TEXT, Session will be closed.


Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
sinax
Posts: 8
Joined: 22 Oct 2018, 18:11

Re: Problem getting examples to work

Postby sinax » 23 Oct 2018, 09:38

This is how the server panel look like:

Image

To make sure I just turned `Use WS binary protocol` off and on and restarted the service. nothing changed
Last edited by sinax on 23 Oct 2018, 10:26, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem getting examples to work

Postby Lapo » 23 Oct 2018, 10:20

Ok.
So in the logs you've sent there's no trace of a client connection made via websocket, which is very puzzling.
You showed that the client connects and attempts to send the handshake message but there's no related server log entry showing the connection.

This is literally not possible, unless your client is connecting somewhere else.
What attracted my attention from your boot.log file is that it seems you're running in a virtual machine and, for some reason, this VM is running a gazillion network cards. If you check that log you will see that there're almost 90 network cards listed!

Here's what I recommend.
Stop the server and start it afresh with sfs2x.bat so that you can see the logs on screen.
Then connect the client example (Advanced Chat is fine), if the client says that a connection was made check the server logs. You should see something like this:

Code: Select all

12:24:19,595 INFO  [qtp451433836-47] sessions.DefaultSessionManager     - Session created: { Id: 4, Type: WEBSOCKET, Logged: No, IP: 0:0:0:0:0:0:0:1 } on Server port: 8080 <---> 58468

The important parts are the "Session created" and "Type: WEBSOCKET".

If there's no such message in the logs, I'd say that something is wrong with your VM and the presence of such an insane amount of virtual NICs is likely the issue. Though I would have no idea how to fix it.

As a side note, I also run a virtual Windows 10 under MacOS using Parallels Desktop and have found no problems with SFS2X, granted my list of network card is less than a 10th of your list.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
sinax
Posts: 8
Joined: 22 Oct 2018, 18:11

Re: Problem getting examples to work

Postby sinax » 23 Oct 2018, 10:45

Well I stopped the service and tried to starting the process using .bat file.

The process started and ten exited with following errors:

Code: Select all

14:05:40,433 INFO  [main] v2.SmartFoxServer     - Boot sequence starts...
14:05:41,277 INFO  [main] core.SFSEventManager     - AnonymousService-1 initialized
14:05:41,310 INFO  [main] impl.DefaultFileReplicator     - Using "C:\Users\sinax\AppData\Local\Temp\vfs_cache" as temporary files store.
14:05:41,406 INFO  [main] v2.SmartFoxServer     - License loaded:

==========================================
LICENSE DETAILS
------------------------------------------
Type            : Community Edition
Max users       : 100
==========================================

14:05:41,408 INFO  [main] managers.SFSBannedUserStorage     - BanUserStorage initialized
14:05:41,426 INFO  [main] managers.SFSBannedUserManager     - BanUser data loaded: 0 records.
14:05:41,469 INFO  [main] v2.SmartFoxServer     - Protocol Type is: BINARY
14:05:41,475 INFO  [main] config.DefaultConfigLoader     - Loading: zones\BasicExamples.zone.xml
14:05:41,513 INFO  [main] managers.SFSZoneManager     -

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 >> Zone: BasicExamples
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

14:05:41,552 INFO  [main] managers.SFSRoomManager     - Room created: { Zone: BasicExamples }, [ Room: The Lobby, Id: 0, Group: default, isGame: false ], type = SFSRoom
14:05:41,563 INFO  [main] managers.SFSRoomManager     - Room created: { Zone: --=={{{ AdminZone }}}==-- }, [ Room: AdminRoom, Id: 1, Group: default, isGame: false ], type = SFSRoom
14:05:41,622 INFO  [main] core.AdminToolService     - AdminTool Service started
14:05:42,453 WARN  [main] bootLogger     - Was not able to bind socket: { 0.0.0.0:9933, (Tcp) }
14:05:42,460 WARN  [main] bootLogger     - Was not able to bind socket: { 127.0.0.1:9933, (Udp) }
14:05:42,528 ERROR [main] bootLogger     - No bound sockets! Check the boot logs for possible problems!
14:05:42,543 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     - Listening Sockets:
14:05:42,546 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     -
 _____ _____ _____    ___ __ __
|   __|   __|   __|  |_  |  |  |
|__   |   __|__   |  |  _|-   -|
|_____|__|  |_____|  |___|__|__|
 _____ _____ _____ ____  __ __
| __  |   __|  _  |    \|  |  |
|    -|   __|     |  |  |_   _|
|__|__|_____|__|__|____/  |_|
[ 2.13.3 ]

14:05:42,546 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     - SmartFoxServer 2X (2.13.3) READY!
14:05:46,201 INFO  [main] v3.SessionFilter     - BlueBox-2X Service (3.1.0) READY.
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:214)
        at org.eclipse.jetty.start.Main.start(Main.java:457)
        at org.eclipse.jetty.start.Main.main(Main.java:75)
        at com.smartfoxserver.v2.http.JettyServer.start(JettyServer.java:35)
        at com.smartfoxserver.v2.SmartFoxServer.start(SmartFoxServer.java:326)
        at com.smartfoxserver.v2.Main.main(Main.java:14)
Caused by: MultiException[java.net.BindException: Address already in use: bind, java.net.BindException: Address already in use: bind]
        at org.eclipse.jetty.server.Server.doStart(Server.java:353)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1510)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1435)
        ... 10 more
        Suppressed: java.net.BindException: Address already in use: bind
                at sun.nio.ch.Net.bind0(Native Method)
                at sun.nio.ch.Net.bind(Unknown Source)
                at sun.nio.ch.Net.bind(Unknown Source)
                at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
                at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
                at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:317)
                at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
                at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
                at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
                at org.eclipse.jetty.server.Server.doStart(Server.java:390)
                ... 14 more
Caused by: java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:317)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:390)
        ... 14 more

Usage: java -jar start.jar [options] [properties] [configs]
       java -jar start.jar --help  # for more information
14:05:46,758 INFO  [Thread-0] managers.SFSZoneManager     - BuddyList saveAll...
14:05:46,766 WARN  [SFS2X ShutdownHook] core.SFSShutdownHook     - SFS2X is shutting down. The process may take a few seconds...
14:05:46,785 INFO  [Thread-1] managers.SFSBannedUserManager     - BanUser data saved.


The strange thing is that after the process termination, I still can connect and use the admin panel. Apparently some other process is running. I'll do some checks and will get back shortly
sinax
Posts: 8
Joined: 22 Oct 2018, 18:11

Re: Problem getting examples to work

Postby sinax » 23 Oct 2018, 10:51

Okay I found that there was a `java.exe` process holding the ports. I have no idea if it's a stale process from SFS2X or it's from another source.

I terminated the process and started the server using .bat and it was working fine.

Then I terminated it and started the service using windows Services console and the clients are still fine connecting to it.

Thank you very much for your sincere help.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem getting examples to work

Postby Lapo » 23 Oct 2018, 14:26

Very weird, I am glad it works now :)

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 14 guests