You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
I could already find out that the embedded Tomcat and OpenLibertySession objects are implemented differently. The Tomcat implementation fills its userProperties with the content of the userProperties of the endpointConfig object while initializing the Session object (in constructor), whereas the OpenLiberty Session implementation doesn't, as you can see here.
In my opinion, it would make sense to adapt the GraphQLWebsocketServlet to use the userProperties of the endpointConfig object, since there is already an indirect usage and it would provide support for an additional WAS...?
apae89
pushed a commit
to apae89/graphql-java-servlet
that referenced
this issue
Oct 1, 2019
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()
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
The text was updated successfully, but these errors were encountered: