How to create a socket in wildfly?

Asked

Viewed 177 times

0

I need to create something that reads everything that comes to a specific door and handles that information. An Ubuntu server is used with Wildfly 10 running. The information trafficked is from the trackers (in this case it is the CRX-1 of Concox and those of Suntech). They send a string with the information encoded in hexadecimal. Treating the data is the easy part... I’m not able to read the port.

NOTE: When testing outside this environment, with common simple socket, the test client socket_connects and transfers information, when it is in wildFly it cannot connect.

I tried to create Web Socket... I was unsuccessful too...

Last code I tried, it was a web socket:

Wsendpoint.java (I took an example on 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 for testing)

           
         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 thing is the JS msm... HTML is basic.. just enough for the page to open..

  • Adds the code of what you tried, sometimes there is an error ;)

  • Wildfly port has been changed from :8080 to :9018 la in [Wildfly]/Configuration/standalone.xml

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.