diff --git a/flow-tests/vaadin-spring-tests/pom.xml b/flow-tests/vaadin-spring-tests/pom.xml
index d4068b1b20c..56fe4b776e3 100644
--- a/flow-tests/vaadin-spring-tests/pom.xml
+++ b/flow-tests/vaadin-spring-tests/pom.xml
@@ -128,6 +128,11 @@
jaxb-api
2.3.1
+
+ javax.websocket
+ javax.websocket-api
+ 1.1
+
org.glassfish.jaxb
jaxb-runtime
diff --git a/flow-tests/vaadin-spring-tests/test-spring-boot-reverseproxy/pom.xml b/flow-tests/vaadin-spring-tests/test-spring-boot-reverseproxy/pom.xml
index 46696de6e8d..4e78b1ae306 100644
--- a/flow-tests/vaadin-spring-tests/test-spring-boot-reverseproxy/pom.xml
+++ b/flow-tests/vaadin-spring-tests/test-spring-boot-reverseproxy/pom.xml
@@ -151,7 +151,7 @@
- *PushIT*
+ *PushIT*,*CustomWebSocketIT*
diff --git a/flow-tests/vaadin-spring-tests/test-spring-common/src/main/java/com/vaadin/flow/spring/test/CustomWebSocket.java b/flow-tests/vaadin-spring-tests/test-spring-common/src/main/java/com/vaadin/flow/spring/test/CustomWebSocket.java
new file mode 100644
index 00000000000..280a8b63527
--- /dev/null
+++ b/flow-tests/vaadin-spring-tests/test-spring-common/src/main/java/com/vaadin/flow/spring/test/CustomWebSocket.java
@@ -0,0 +1,54 @@
+package com.vaadin.flow.spring.test;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.CloseStatus;
+import org.springframework.web.socket.TextMessage;
+import org.springframework.web.socket.WebSocketHandler;
+import org.springframework.web.socket.WebSocketMessage;
+import org.springframework.web.socket.WebSocketSession;
+import org.springframework.web.socket.config.annotation.EnableWebSocket;
+import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
+import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
+
+@Configuration
+@EnableWebSocket
+public class CustomWebSocket implements WebSocketConfigurer {
+
+ public static final String WEBSOCKET_URL = "/customWebSocket";
+
+ public static final String WEBSOCKET_RESPONSE_TEXT = "This is a response from Web Socket!";
+
+ @Override
+ public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
+ registry.addHandler(new WebSocketHandler() {
+
+ @Override
+ public void afterConnectionEstablished(WebSocketSession session) {
+ }
+
+ @Override
+ public void handleMessage(WebSocketSession session,
+ WebSocketMessage> message) throws Exception {
+ session.sendMessage(new TextMessage(WEBSOCKET_RESPONSE_TEXT));
+ }
+
+ @Override
+ public void handleTransportError(WebSocketSession session,
+ Throwable exception) {
+
+ }
+
+ @Override
+ public void afterConnectionClosed(WebSocketSession session,
+ CloseStatus closeStatus) {
+
+ }
+
+ @Override
+ public boolean supportsPartialMessages() {
+ return false;
+ }
+ }, WEBSOCKET_URL);
+ }
+
+}
diff --git a/flow-tests/vaadin-spring-tests/test-spring-common/src/test/java/com/vaadin/flow/spring/test/CustomWebSocketIT.java b/flow-tests/vaadin-spring-tests/test-spring-common/src/test/java/com/vaadin/flow/spring/test/CustomWebSocketIT.java
new file mode 100644
index 00000000000..4a3d9499da3
--- /dev/null
+++ b/flow-tests/vaadin-spring-tests/test-spring-common/src/test/java/com/vaadin/flow/spring/test/CustomWebSocketIT.java
@@ -0,0 +1,72 @@
+package com.vaadin.flow.spring.test;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.CloseReason;
+import javax.websocket.ContainerProvider;
+import javax.websocket.OnClose;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import javax.websocket.WebSocketContainer;
+import java.io.IOException;
+import java.net.URI;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(SpringBootOnly.class)
+public class CustomWebSocketIT extends AbstractSpringTest {
+
+ @ClientEndpoint
+ public class CustomWebSocketEndpoint {
+
+ private final CountDownLatch closureLatch = new CountDownLatch(1);
+
+ private String message;
+
+ @OnMessage
+ public void onMessage(Session session, String message)
+ throws IOException {
+ this.message = message;
+ session.close();
+ }
+
+ @OnClose
+ public void onClose(CloseReason reason) {
+ closureLatch.countDown();
+ }
+
+ public String waitForMessage() throws InterruptedException {
+ closureLatch.await(1, TimeUnit.SECONDS);
+ return message;
+ }
+ }
+
+ @Test
+ public void properWebsocketResponseIsReceived() throws Exception {
+ WebSocketContainer container = ContainerProvider
+ .getWebSocketContainer();
+
+ String testUrl = getTestURL().replace("http://", "ws://");
+ URI uri = URI.create(testUrl + CustomWebSocket.WEBSOCKET_URL);
+
+ try {
+ CustomWebSocketEndpoint clientEndpoint = new CustomWebSocketEndpoint();
+ Session session = container.connectToServer(clientEndpoint, uri);
+ session.getBasicRemote().sendText("Hello");
+ Assert.assertEquals(CustomWebSocket.WEBSOCKET_RESPONSE_TEXT,
+ clientEndpoint.waitForMessage());
+ session.close();
+ } catch (Exception ex) {
+ throw ex;
+ }
+ }
+
+ @Override
+ protected String getTestPath() {
+ return "";
+ }
+
+}
diff --git a/flow-tests/vaadin-spring-tests/test-spring-war/pom.xml b/flow-tests/vaadin-spring-tests/test-spring-war/pom.xml
index fd4dbbb5703..f3440191356 100644
--- a/flow-tests/vaadin-spring-tests/test-spring-war/pom.xml
+++ b/flow-tests/vaadin-spring-tests/test-spring-war/pom.xml
@@ -59,6 +59,34 @@
+
+
+
+ org.eclipse.jetty
+ jetty-client
+ ${jetty.version}
+
+
+ org.eclipse.jetty
+ jetty-util
+ ${jetty.version}
+
+
+ org.eclipse.jetty
+ jetty-http
+ ${jetty.version}
+
+
+ org.eclipse.jetty
+ jetty-io
+ ${jetty.version}
+
+
+ org.eclipse.jetty.websocket
+ websocket-javax-client
+ ${jetty.version}
+
+
diff --git a/vaadin-spring/src/main/java/com/vaadin/flow/spring/SpringBootAutoConfiguration.java b/vaadin-spring/src/main/java/com/vaadin/flow/spring/SpringBootAutoConfiguration.java
index c82330994a7..93f01fce551 100644
--- a/vaadin-spring/src/main/java/com/vaadin/flow/spring/SpringBootAutoConfiguration.java
+++ b/vaadin-spring/src/main/java/com/vaadin/flow/spring/SpringBootAutoConfiguration.java
@@ -101,6 +101,7 @@ public ServletRegistrationBean servletRegistrationBean(
*/
initParameters.put(ApplicationConfig.JSR356_MAPPING_PATH,
pushRegistrationPath);
+ initParameters.put(ApplicationConfig.JSR356_PATH_MAPPING_LENGTH, "0");
ServletRegistrationBean registration = new ServletRegistrationBean<>(
new SpringServlet(context, rootMapping), mapping);
diff --git a/vaadin-spring/src/main/java/com/vaadin/flow/spring/VaadinMVCWebAppInitializer.java b/vaadin-spring/src/main/java/com/vaadin/flow/spring/VaadinMVCWebAppInitializer.java
index 2349095e230..0419b0e62d2 100644
--- a/vaadin-spring/src/main/java/com/vaadin/flow/spring/VaadinMVCWebAppInitializer.java
+++ b/vaadin-spring/src/main/java/com/vaadin/flow/spring/VaadinMVCWebAppInitializer.java
@@ -85,6 +85,7 @@ public void onStartup(ServletContext servletContext)
*/
initParameters.put(ApplicationConfig.JSR356_MAPPING_PATH,
pushRegistrationPath);
+ initParameters.put(ApplicationConfig.JSR356_PATH_MAPPING_LENGTH, "0");
registration.setInitParameters(initParameters);