I am following the jBoss documentation to include a websocket in a service built with jBoss 7.
I have created and interface and its implementation with the required annotations:
@ServerEndpoint("/websocket/helloworld")
public interface MyService {
@OnMessage
String sayHello(String name);
@OnOpen
void helloOnOpen(Session session);
@OnClose
void helloOnClose(CloseReason reason);
}
and also I have added the required dependency in the parent pom and the weblayer where the controller is.
<dependency>
<groupId>org.jboss.spec.javax.websocket</groupId>
<artifactId>jboss-websocket-api_1.0_spec</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
The websocket is not handled correclty, and I am not able to be connected to it. Reviewing the server access log I can see that I am reaching the server
{"ident": "-","auth": "-","logdate": "[30/Aug/2023:18:20:36 +0200]","client": {"ip": "172.18.0.1","user_agent": "-"},"verb": "GET","http": {"protocol": "HTTP/1.1","request": {"path": "/genesys-chat/websocket/helloworld","clientVersion": "-","query-string": "-"},"response": {"status": "404","bytes": "68","time": "5"}}, "type":"standard", "logname":"jbossweb_access.log"}
As you can see the request is handled a normal HTTP GET request. Debugging I can see that the handled used by undertow is the HTTP one.
The request done is with postman pointing to
ws://localhost:8080/genesys-chat/websocket/helloworld
Do I miss something?
For starters you need to write an implementation not an interface, please look at the list of published quick starts