I'm trying to integrate a Websocket Server in my Sip-Servlet application made with Restcomm on JBoss AS 7.2.0.Final "Janus". I'm following the steps of the guide in this link.
I'm trying to connect on it with a node server that I have already used to connect with different WS servers and it works. Here the code of node:
var networkNode = new ws('ws://192.168.1.220:5082/websocket/helloName');
networkNode.on('open', function open() {
console.log('connected');
});
Note that the guide says to use 8080 port but: 1. If I use port 8080 node.js gives me a message like "Connection error: Error: unexpected server response (404)" 2. If I use port 5082 it says "connected" but I can't see any log message into the Jboss terminal.
Here the portion of Java code of my Sip-Servlet Application:
package org.mobicents.servlet.sip.example;
//other imports...
import javax.websocket.CloseReason;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
@ServerEndpoint("/websocket/helloName")
//here I have some attributes.
public class SimpleSipServlet extends SipServlet implements SipErrorListener,
Servlet {
...
@OnOpen
public void helloOnOpen(Session session) {
logger.info("WebSocket opened: " + session.getId();
}
//And so on...
Is there something wrong in my logic/code? I think I'm pointing to the wrong listener, right? How can I know the right path of my WebSocket Server? Thank you in advice.
Restcomm SIP Servlets uses a separate connector for WebSockets on port 5082 for WS and 5083 for WSS. this specific WebSocket connector is intended to support only SIP Over Websockets and is tightly integrated with the underlying SIP Stack.
So it depends what is the intent of your application. If you intend to handle SIP Over WebSockets traffic using 5082 is the right thing to do otherwise if it's only to handle regular WebSockets traffic using 8080 is the one to use.
You may also want to try using Restcomm SIP Servlets on Wildfly 10 early versions from https://mobicents.ci.cloudbees.com/job/RestcommSipServlets-4.X-Release/. It passes the TCK and may have a more up to date WebSockets implementation for the HTTP side.