lighttpdmod_wstunnel连接JSON消息

问题描述 投票:0回答:1

我想用 lighttpd (v1.4.49) 与 mod_wstunnel.

$HTTP["url"] =~ "^/websocket" {
    wstunnel.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "50007" ) ) )
    wstunnel.frame-type = "text"
    wstunnel.ping-interval = 30
}

后端 TCP-Server 发送单行 JSON 消息,WebSocket-Clients 应该收到这些消息。onmessage 处理器。

然而,有时两个连续的消息会由 mod_wstunnel 并收到(并传递给 onmessage)作为一条消息。

有没有什么 "消息结束 "的令牌可以让我明确地 "告诉" mod_wstunnel 信息是否完整?

谢谢,Sam

websocket lighttpd
1个回答
0
投票

如果你的应用依赖于websockets层的frame,你可能应该修复你的应用。 请看 https:/tools.ietf.orghtmlrfc6455#section-5.4

Unless specified otherwise by an extension, frames have no semantic
meaning. An intermediary might coalesce and/or split frames, if no
extensions were negotiated by the client and the server or if some
extensions were negotiated, but the intermediary understood all the
extensions negotiated and knows how to coalesce and/or split frames
in the presence of these extensions. One implication of this is that
in absence of extensions, senders and receivers must not depend on
the presence of specific frame boundaries.

您的后台正在发送JSON,对websocket一无所知,因此不能指定mod_wstunnel应该如何发送websocket框架。 你的客户端应用不应该依赖于websocket框架,但如果你想尝试在服务器端缓解这个问题,你的后端可以在发送每个JSON消息之间暂停。 最好是将你的应用程序固定为一次处理完整的JSON消息。

© www.soinside.com 2019 - 2024. All rights reserved.