Description
Hi,
We're facing an issue with Subscriptions when running our GraphQL Spring Boot app (embedded webserver deactivated) within an OpenLiberty webserver. When executing our app in context of the embedded Tomcat everything is working fine.
When executing within OpenLiberty there is a NullPointerException being thrown in class GraphQLWebsocketServlet in method onOpen()
public void onOpen(final Session session, EndpointConfig endpointConfig) {
final WsSessionSubscriptions subscriptions = new WsSessionSubscriptions();
final HandshakeRequest request = (HandshakeRequest)session.getUserProperties().get(HANDSHAKE_REQUEST_KEY);
final SubscriptionProtocolHandler subscriptionProtocolHandler = (SubscriptionProtocolHandler)session.getUserProperties().get(PROTOCOL_HANDLER_REQUEST_KEY);
synchronized(this.cacheLock) {
if (this.isShuttingDown.get()) {
throw new IllegalStateException("Server is shutting down!");
}
this.sessionSubscriptionCache.put(session, subscriptions);
}
log.debug("Session opened: {}, {}", session.getId(), endpointConfig);
session.addMessageHandler(new Whole<String>() {
public void onMessage(String text) {
try {
subscriptionProtocolHandler.onMessage(request, session, subscriptions, text);
} catch (Throwable var3) {
GraphQLWebsocketServlet.log.error("Error executing websocket query for session: {}", session.getId(), var3);
GraphQLWebsocketServlet.this.closeUnexpectedly(session, var3);
}
}
});
}
The NPE is being thrown when accessing subscriptionProtocolHandler within onMessage(). While debugging within OpenLiberty I found out that the userProperties Map of the session object used to create subscriptionProtocolHandler is empty. When executing within embedded Tomcat its contains instances of ApolloSubscriptionProtocolHandler and WsHandshakeRequest. Interestingly these objects are present in the userProperties Map of the endpointConfig (second argument).
Do I need some extra configuration when using Subscriptions within external webserver? Can anyone give me a solution to this?
Many thanks in advance,
Andreas