vertx-eventbus-bridge-clients
vertx-eventbus-bridge-clients copied to clipboard
Unhandled TextWebSocketFrame
Questions
When "url" contains "server" and "transports" instead of the default "/eventbus/websocket" (e.g. " eventbus/1234/EventBusClientA/websocket"), will appear abnormal information and disconnected, Unhandled exception information is "TextWebSocketFrame (data: PooledUnsafeDirectByteBuf(ridx: 0, widx: 18, cap: 18))" Here is my test code:
package org.wjw.vertx.eventbus.bridge;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import io.vertx.eventbusclient.DeliveryOptions;
import io.vertx.eventbusclient.EventBusClient;
import io.vertx.eventbusclient.EventBusClientOptions;
import io.vertx.eventbusclient.Handler;
import io.vertx.eventbusclient.Message;
public class MainConsumer {
private static int MAX_WEBSOCKET_FRAME_SIZE = 1024 * 1024;
private static String server="9999"; //String to append to url for actual data connection. Defaults to a random 4 digit number.
private static String sessionId="EventBusClientA"; //Both client and server use session identifiers to distinguish connections.
public static void main(String[] args) {
EventBusClientOptions options = new EventBusClientOptions()
.setHost("127.0.0.1")
.setPort(9090)
.setAutoReconnect(true)
.setWebSocketPath("/eventbus/"+server+"/"+sessionId+"/websocket") //A WebSocket was created,uri: /eventbus/843/zsqys1m5/websocket
//.setWebSocketPath("/eventbus/websocket")
.setMaxWebSocketFrameSize(MAX_WEBSOCKET_FRAME_SIZE);
EventBusClient busClient = EventBusClient.webSocket(options);
//set headers
DeliveryOptions deliveryOptions = new DeliveryOptions().addHeader("myid", "EventBusClient");
busClient.setDefaultDeliveryOptions(deliveryOptions);
busClient.consumer("auction.1", new Handler<Message<Map>>() {
@Override
public void handle(Message<Map> message) {
System.out.println("Received a news " + message.body());
}
});
System.out.println("input quit/exit to call System.exit() and run the shutdown routine.");
startIdeConsole(busClient);
}
static private void startIdeConsole(EventBusClient busClient) {
Thread inputThread = new Thread(() -> {
boolean loopz = true;
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
while (loopz) {
String userInput = br.readLine();
System.out.println("input => " + userInput);
if (userInput.equalsIgnoreCase("quit") || userInput.equalsIgnoreCase("exit")) {
busClient.close();
System.out.println("Shutdown hook run.");
System.exit(0);
}
}
} catch (Exception er) {
er.printStackTrace();
loopz = false;
}
});
inputThread.setDaemon(true);
inputThread.start();
}
}
Version
Vert.x 4.3.8 & vertx-eventbus-bridge-clients 1.0.1
Error Message:
二月 12, 2023 1:49:16 下午 io.vertx.eventbusclient.EventBusClient connectTransport
信息: Connecting to bridge at 127.0.0.1:9090 using WebSocketTransport...
input quit/exit to call System.exit() and run the shutdown routine.
二月 12, 2023 1:49:16 下午 io.vertx.eventbusclient.EventBusClient$1 handle
信息: Connected to bridge.
二月 12, 2023 1:49:16 下午 io.vertx.eventbusclient.EventBusClient handlePendingTasks
信息: Registering address: auction.1
二月 12, 2023 1:49:16 下午 io.vertx.eventbusclient.EventBusClient$8 handle
信息: Sending message: {"headers":{"myid":"EventBusClient"},"address":"auction.1","type":"register"}
Unhandled TextWebSocketFrame(data: PooledUnsafeDirectByteBuf(ridx: 0, widx: 1, cap: 1))
二月 12, 2023 1:49:21 下午 io.vertx.eventbusclient.EventBusClient$8 handle
信息: Sending message: {"type":"ping"}
二月 12, 2023 1:49:26 下午 io.vertx.eventbusclient.EventBusClient$8 handle
信息: Sending message: {"type":"ping"}
Unhandled TextWebSocketFrame(data: PooledUnsafeDirectByteBuf(ridx: 0, widx: 18, cap: 18))
二月 12, 2023 1:49:26 下午 io.vertx.eventbusclient.EventBusClient$3 handle
信息: Closed connection to bridge.
二月 12, 2023 1:49:26 下午 io.vertx.eventbusclient.EventBusClient autoReconnect
信息: Auto reconnecting in 3000ms (try number 1)...
二月 12, 2023 1:49:30 下午 io.vertx.eventbusclient.EventBusClient$5 run
信息: Auto reconnecting...
二月 12, 2023 1:49:30 下午 io.vertx.eventbusclient.EventBusClient connectTransport
信息: Connecting to bridge at 127.0.0.1:9090 using WebSocketTransport...
二月 12, 2023 1:49:30 下午 io.vertx.eventbusclient.EventBusClient$1 handle
信息: Connected to bridge.
二月 12, 2023 1:49:30 下午 io.vertx.eventbusclient.EventBusClient handlePendingTasks
信息: Registering address: auction.1
二月 12, 2023 1:49:30 下午 io.vertx.eventbusclient.EventBusClient$8 handle
信息: Sending message: {"headers":{"myid":"EventBusClient"},"address":"auction.1","type":"register"}
Unhandled TextWebSocketFrame(data: PooledUnsafeDirectByteBuf(ridx: 0, widx: 1, cap: 1))
二月 12, 2023 1:49:35 下午 io.vertx.eventbusclient.EventBusClient$8 handle
信息: Sending message: {"type":"ping"}
二月 12, 2023 1:49:40 下午 io.vertx.eventbusclient.EventBusClient$8 handle
信息: Sending message: {"type":"ping"}
Unhandled TextWebSocketFrame(data: PooledUnsafeDirectByteBuf(ridx: 0, widx: 18, cap: 18))
二月 12, 2023 1:49:40 下午 io.vertx.eventbusclient.EventBusClient$3 handle
信息: Closed connection to bridge.
二月 12, 2023 1:49:40 下午 io.vertx.eventbusclient.EventBusClient autoReconnect
信息: Auto reconnecting in 3000ms (try number 1)...
我遇到了相同的问题, 请问你解决了吗?
我遇到了相同的问题, 请问你解决了吗?
你用的哪个版本的?你试试4.4.9版本
我遇到了相同的问题, 请问你解决了吗?
如果自定义eventbus路径,不能发送JSON对象,需要发送字符串.