Problem with Secure Websockets (WSS)

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

hhd90
Posts: 67
Joined: 21 Dec 2012, 05:17

Problem with Secure Websockets (WSS)

Postby hhd90 » 19 Jul 2014, 03:53

Hi smartfox team,
I just update my sever to version 2.9.0 and have a problem with wss. I run test locally with this config :

Code: Select all

  <webSocket>
    <isActive>true</isActive>
    <bindAddress>192.168.1.253</bindAddress>
    <tcpPort>8887</tcpPort>
   <sslPort>8843</sslPort>
   <isSSL>false</isSSL>
    <keyStoreFile>config/keystore.jks</keyStoreFile>
    <keyStorePassword>password</keyStorePassword>
  </webSocket>

if the setting isSSL =false and client connect to sever. It runs normally and does not have any problem
if the setting isSSL =true and client connect via link https://192.168.1.253:8843/ella/ (ella is my client folder in root)
The browser show a warning page as the doc describes. But it cannot connect and server show error

Code: Select all

19 Jul 2014 | 09:55:34,688 | WARN  | New I/O worker #5 | websocket.netty.WebSocketServerHandler |     | org.jboss.netty.handler.codec.http.websocketx.WebSocketHandshakeException: not a WebSocket handshake request: missing upgrade
19 Jul 2014 | 09:55:34,733 | INFO  | New I/O worker #5 | bitswarm.sessions.DefaultSessionManager |     | Session removed: { Id: 53, Type: WEBSOCKET, Logged: No, IP: 192.168.1.253:56190


client API : SFS2X_API_JavaScript_v1.2.0
client browser : Chrome Version 36.0.1985.125 m

How do I fix this ?

Thanks !
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem with Secure Websockets (WSS)

Postby Lapo » 19 Jul 2014, 08:19

Did you also set the useSSL flag in the client API?

Example:

Code: Select all

// Create configuration object
var config = {};
config.host = "127.0.0.1"
config.port = 8843
config.zone = "BasicExamples";
config.useSSL = true;

// Create SmartFox client instance
sfs = new SmartFox(config);
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem with Secure Websockets (WSS)

Postby Lapo » 19 Jul 2014, 08:22

You will also need to manually force the browser to accept the SSL self-signed certificate, as explained here:
http://docs2x.smartfoxserver.com/Gettin ... eb-sockets
See the "Testing with a self-signed certificate" section

Unfortunately it's a bit of a pain but there's no way around it, that's how browser security works :(
Lapo

--

gotoAndPlay()

...addicted to flash games
hhd90
Posts: 67
Joined: 21 Dec 2012, 05:17

Re: Problem with Secure Websockets (WSS)

Postby hhd90 » 20 Jul 2014, 19:06

Where is the location of https home folder. I put my client in the folder /www/root and get method notifys error null response when go to the link https://myip:wssport/client. If I just go to link https://myip:wssport, it show the { SFS2X Websocket Index Page } where is the location of this page ?

I already have an SSL certificate via https://mydomain. Do I need a new SSL certificate for wss://mydomain ?
hhd90
Posts: 67
Joined: 21 Dec 2012, 05:17

Re: Problem with Secure Websockets (WSS)

Postby hhd90 » 21 Jul 2014, 04:38

I also encounter a strange error. My client API : SFS2X_API_JavaScript_v1.2.0 and server version : 2.9.0
Program run locally on window 7 or run on window server 2008, everything is OK but if I run on Linux OS, client can not connect to server.
My OS info :

Code: Select all

Linux version 2.6.32-358.23.2.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Wed Oct 16 18:37:12 UTC 2013

Java version info

Code: Select all

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)


error on server

Code: Select all

10:40:43,643 WARN  [New I/O  worker #2] netty.WebSocketServerHandler     - java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.headers()Lorg/jboss/netty/handler/codec/http/HttpHeaders;
10:40:43,644 INFO  [New I/O  worker #2] sessions.DefaultSessionManager     - Session removed: { Id: 2, Type: WEBSOCKET, Logged: No, IP: 117.6.79.157:51959 }



error on client

Code: Select all

[INFO] SmartFox instance ready! SFS2X_API_JS.js:175
WebSocket connection to 'ws://123.30.177.44:8888/websocket' failed: Connection closed before receiving a handshake response SFS2X_API_JS.js:301
[ERROR] You are not connected. Request cannot be sent: Login


client config

Code: Select all

   var config = {};
   config.host = "serverIp";
   config.port =  8888;
   config.zone = 'GameZone';
   config.useSSL = false;
   config.debug = 1;
   sfs = new SmartFox(config);


server config

Code: Select all

  <webSocket>
    <isActive>true</isActive>
    <bindAddress>serverip</bindAddress>
    <tcpPort>8888</tcpPort>
   <sslPort>8843</sslPort>
   <isSSL>false</isSSL>
    <keyStoreFile>config/keystore.jks</keyStoreFile>
    <keyStorePassword>password</keyStorePassword>
  </webSocket>
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem with Secure Websockets (WSS)

Postby Lapo » 21 Jul 2014, 07:28

hhd90 wrote:Where is the location of https home folder. I put my client in the folder /www/root and get method notifys error null response when go to the link https://myip:wssport/client. If I just go to link https://myip:wssport, it show the { SFS2X Websocket Index Page } where is the location of this page ?

I already have an SSL certificate via https://mydomain. Do I need a new SSL certificate for wss://mydomain ?

Yes they are not the same thing.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem with Secure Websockets (WSS)

Postby Lapo » 21 Jul 2014, 08:09

hhd90 wrote:error on server

Code: Select all

10:40:43,643 WARN  [New I/O  worker #2] netty.WebSocketServerHandler     - java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.headers()Lorg/jboss/netty/handler/codec/http/HttpHeaders;
10:40:43,644 INFO  [New I/O  worker #2] sessions.DefaultSessionManager     - Session removed: { Id: 2, Type: WEBSOCKET, Logged: No, IP: 117.6.79.157:51959 }

We saw this error on some Linux distributions after the release and we uploaded a new Linux installer.
I would suggest to download it again and performa a new installation. It should fix the problem.

Sorry for the inconvenience.
Lapo

--

gotoAndPlay()

...addicted to flash games
hhd90
Posts: 67
Joined: 21 Dec 2012, 05:17

Re: Problem with Secure Websockets (WSS)

Postby hhd90 » 21 Jul 2014, 10:08

Where is the location of https home folder. I put my client in the folder /www/root and get method notifys error null response when go to the link https://myip:wssport/client. If I just go to link https://myip:wssport, it show the { SFS2X Websocket Index Page } where is the location of this page ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem with Secure Websockets (WSS)

Postby Lapo » 21 Jul 2014, 10:26

For HTTP/HTTPS files you must use the www/root/ folder
Lapo

--

gotoAndPlay()

...addicted to flash games
hhd90
Posts: 67
Joined: 21 Dec 2012, 05:17

Re: Problem with Secure Websockets (WSS)

Postby hhd90 » 29 Jul 2014, 07:41

hhd90 wrote:I also encounter a strange error. My client API : SFS2X_API_JavaScript_v1.2.0 and server version : 2.9.0
Program run locally on window 7 or run on window server 2008, everything is OK but if I run on Linux OS, client can not connect to server.
My OS info :

Code: Select all

Linux version 2.6.32-358.23.2.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Wed Oct 16 18:37:12 UTC 2013

Java version info

Code: Select all

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)


error on server

Code: Select all

10:40:43,643 WARN  [New I/O  worker #2] netty.WebSocketServerHandler     - java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.headers()Lorg/jboss/netty/handler/codec/http/HttpHeaders;
10:40:43,644 INFO  [New I/O  worker #2] sessions.DefaultSessionManager     - Session removed: { Id: 2, Type: WEBSOCKET, Logged: No, IP: 117.6.79.157:51959 }



error on client

Code: Select all

[INFO] SmartFox instance ready! SFS2X_API_JS.js:175
WebSocket connection to 'ws://123.30.177.44:8888/websocket' failed: Connection closed before receiving a handshake response SFS2X_API_JS.js:301
[ERROR] You are not connected. Request cannot be sent: Login


client config

Code: Select all

   var config = {};
   config.host = "serverIp";
   config.port =  8888;
   config.zone = 'GameZone';
   config.useSSL = false;
   config.debug = 1;
   sfs = new SmartFox(config);


server config

Code: Select all

  <webSocket>
    <isActive>true</isActive>
    <bindAddress>serverip</bindAddress>
    <tcpPort>8888</tcpPort>
   <sslPort>8843</sslPort>
   <isSSL>false</isSSL>
    <keyStoreFile>config/keystore.jks</keyStoreFile>
    <keyStorePassword>password</keyStorePassword>
  </webSocket>


Dear Lapo, I have just installed from a new installer but the error can not fix

Code: Select all

13:49:41,272 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     - SmartFoxServer 2X (2.9.0) READY!
13:49:52,502 INFO  [New I/O  worker #1] sessions.DefaultSessionManager     - Session created: { Id: 1, Type: WEBSOCKET, Logged: No, IP: 117.6.79.157 } on Server port: 8888 <---> 60410
13:49:52,915 WARN  [New I/O  worker #1] netty.WebSocketServerHandler     - java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.headers()Lorg/jboss/netty/handler/codec/http/HttpHeaders;
13:49:52,915 INFO  [New I/O  worker #1] sessions.DefaultSessionManager     - Session removed: { Id: 1, Type: WEBSOCKET, Logged: No, IP: 117.6.79.157:60410 }
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem with Secure Websockets (WSS)

Postby Lapo » 29 Jul 2014, 09:15

What version of CentOS is this exactly? 5? 6? 7?
thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
hhd90
Posts: 67
Joined: 21 Dec 2012, 05:17

Re: Problem with Secure Websockets (WSS)

Postby hhd90 » 30 Jul 2014, 03:26

Lapo wrote:What version of CentOS is this exactly? 5? 6? 7?
thanks

My OS is

Code: Select all

CentOS release 6.4 (Final)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem with Secure Websockets (WSS)

Postby Lapo » 30 Jul 2014, 08:53

I think there's something wrong on your end because we have no problems running SFS2X 2.9 on CentOS.

I have just setup a CentOS 6.4 installation in a VM, downloaded SFS2X and run it, as you can see the websocket client is able to connect.
See attached picture.

centos6.png
CentOS6
(57.91 KiB) Not downloaded yet


I can't think of a specific reason for your problem. My suggestion is to try another server. If you are running in the cloud try spawning a new machine.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 18 guests