Search code examples
spring-bootgraphqlgraphql-java

Spring Boot GraphQL Subscription returns 405 METHOD_NOT_ALLOWED


I'm using Spring Boot with GraphQL, and my subscriptions are not working as expected. Specifically, when trying to make a subscription request, the server responds with 405 METHOD_NOT_ALLOWED.

Here’s the relevant part of the logs:

2025-01-16T16:17:49.484+03:00 DEBUG 8468 --- [blogit] [nio-8000-exec-4] o.s.security.web.FilterChainProxy : Securing GET /graphql 2025-01-16T16:17:49.484+03:00 DEBUG 8468 --- [blogit] [nio-8000-exec-4] o.s.web.servlet.DispatcherServlet : Completed 405 METHOD_NOT_ALLOWED 2025-01-16T16:17:49.500+03:00 DEBUG 8468 --- [blogit] [nio-8000-exec-3] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header java.io.EOFException: null at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1293) ~[tomcat-embed-core-10.1.34.jar:10.1.34] at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:792) ~[tomcat-embed-core-10.1.34.jar:10.1.34]

What I've tried:

  1. Ensured that the graphql-spring-boot-starter dependency is included.
  2. Configured subscriptions in the GraphQL schema.
  3. Verified WebSocket configuration in Spring Boot.

Solution

  • Eventually, the issue was the absence of the following entry in application.properties:

    spring.graphql.websocket.path=/graphql
    

    I added this, and it started working.

    I found this example from https://github.com/spring-projects/spring-graphql-examples