Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否支持socketjs+stomp? #254

Open
zwb993 opened this issue Jul 21, 2023 · 1 comment
Open

是否支持socketjs+stomp? #254

zwb993 opened this issue Jul 21, 2023 · 1 comment

Comments

@zwb993
Copy link

zwb993 commented Jul 21, 2023

能否给个前后端的demo,以及是否支持stomp协议的订阅?

@zwb993
Copy link
Author

zwb993 commented Jul 21, 2023

现在是使用socketjs+stomp:
`const socket = new SockJS("/websocket");
stompClient = Stomp.over(socket);
stompClient.heartbeat.outgoing = 20000;
stompClient.heartbeat.incoming = 20000;

return new Promise((resolve, reject) => {
	if (!stompClient) {
		return reject();
	}
	stompClient.connect(
		headers, //init里面赋header
		() => {
			//成功回调
			if (!stompClient) {
				return reject();
			}
			console.log('已建立连接')
			resolve(stompClient);
		},`

返回403
查看返回的源码,在HttpServerHandler中:
` if (!req.headers().contains(UPGRADE) || !req.headers().contains(SEC_WEBSOCKET_KEY) || !req.headers().contains(SEC_WEBSOCKET_VERSION)) {

if (forbiddenByteBuf != null) {
res = new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN, forbiddenByteBuf.retainedDuplicate());
} else {
res = new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN);
}
sendHttpResponse(ctx, req, res);
return;
}`
socketjs第一次是以http调用,确实未携带upgrade等头部,是不是意味着这不支持socketjs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant