I am connecting to a websocket server in Java using javax.websocket
classes.
import javax.websocket.DeploymentException;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
import java.io.IOException;
import java.net.URI;
public class WSClient {
private WebSocketContainer webSocketContainer;
public void sendMessage(URI endpointURI, String message) throws IOException, DeploymentException {
Session session = webSocketContainer.connectToServer(MyClientEndpoint.class, endpointURI);
session.getAsyncRemote().sendText(message);
}
}
For the initial HTTP handshake I want to add extra HTTP Headers to the request on the Client side
Is this possible?
I know that this is possible on server side using ServerEndpointConfig.Configurator.modifyHandshake
. Is there a similar solution on client side?