How to create a socket in wildfly?

0

I need to create something that reads everything that arrives on a specific port and treat that information. An Ubuntu server with WildFly 10 running is used. The information passed is from the trackers (in this case it is Concox's CRX-1 and SunTech's). They send a String with the information encoded in hexadecimal. Handling the data is the easy part ... I can not read the port.

NOTE: When testing out of this environment, with common simple socket, the socket_test client connects and transfers information, when it is in wildFly it can not connect.

I tried to create Web Socket ... I did not succeed too ...

The last code I tried was a web socket:

WSEndpoint.java (I took an example from the net to test)

package web_socket;

import java.io.IOException;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.enterprise.concurrent.ManagedExecutorService;
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;

import org.jboss.logging.Logger;

@ServerEndpoint("/vs_gateway")
@Stateless
public class WSEndpoint {
    Logger log = Logger.getLogger(this.getClass());
    @Resource
    ManagedExecutorService mes;

    @OnMessage
    public String receiveMessage(String message, Session session) {
        log.info("Received : "+ message + ", session:" + session.getId());
        return "Response from the server";
    }

    @OnOpen
    public void open(Session session) {
        log.info("Open session:" + session.getId());
        final Session s = session;
        mes.execute(new Runnable() {
            @Override
            public void run() {             
                try {
                    for (int i=0;i

index.html (from the same internet example to test)

           
         var ws = new WebSocket("ws://localhost:9018/web_socket/vs_gateway");
         ws.onopen = function()
         {
            alert("Web Socket is connected!!");                 
         };
         ws.onmessage = function (evt) 
         {                  
            var msg = evt.data;
            alert("Message received:" +  msg);
         };
         ws.onclose = function()
         { 
            alert("Connection is closed..."); 
         };

      

NOTE: I could not put the HTML ... but the bid is the JS msm ... HTML is the basic .. just enough for the page to open ..

    
asked by anonymous 08.02.2017 / 20:30

0 answers