0

In my Java EE - Eclipse Oxygen environment with tomcat9 the port is always -1(should be 62114)!

@OnOpen
@Encoded
public void onOpen(@PathParam("BenutzerID") Long BenutzerID, @PathParam("Grad") long Kontaktgrad,
        @PathParam("Accesskey") String Accesskey, Session session, EndpointConfig config) {

    this.port = session.getRequestURI().getPort(); 

1 Answers1

0

If the port is not defined, the getPort() method will return -1. That's the case when the default port is used.

  • 80 is the default port for http and ws URI schemes.
  • 443 is the default port for https and wss URI schemes.

From the RFC 6455, the document that defines the WebSocket protocol:

By default, the WebSocket Protocol uses port 80 for regular WebSocket connections and port 443 for WebSocket connections tunneled over Transport Layer Security (TLS).

Community
  • 1
  • 1
cassiomolin
  • 124,154
  • 35
  • 280
  • 359