Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request or Session scope in Spring Websocket

From WebSocket Endpoint I try to call Singleton Service. But I an unable to use Request or Session scope from WebSocket.

(@Scope( value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS))

I get Scope 'request' is not active for the current thread; For 'request' or 'session' scope on any 'ScopedProxyMode'.

Thanks for the help!

like image 811
Tonci Jelavic Avatar asked Nov 10 '22 07:11

Tonci Jelavic


1 Answers

For web sockets there are no request/response so the request scope is invalid. They introduced new scope called websocket in Spring 4.1. @Scope(name = "websocket", proxyMode = ScopedProxyMode.TARGET_CLASS). Example reference link

http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#websocket-stomp-websocket-scope

like image 153
Abhinay Avatar answered Nov 15 '22 07:11

Abhinay