Clivern / Beaver

💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps.

Home Page:https://clivern.github.io/Beaver/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not recieve message from subscribed channel

david6228 opened this issue · comments

Can create channel, client, subscribe channel, sucessly connected js client, and sucess publish message to channel.
but can not recieve message from subscribed channel.

  • OS: Window 7
  • Beaver: beaver_1.5.0_Windows_i386,default config

detail:
create a channel "app_x_chatroom_1"

create two clients which subscribe "app_x_chatroom_1"

{"channels":["app_x_chatroom_1"],"created_at":1691757017,"id":"8f38aa87-a388-4d67-b2cb-489a95f57bbb","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiOGYzOGFhODctYTM4OC00ZDY3LWIyY2ItNDg5YTk1ZjU3YmJiQDE2OTE3NTcwMTciLCJ0aW1lc3RhbXAiOjE2OTE3NTcwMTd9.sQunm5HkSbsaW2aorHMEtNBGUyG39xVtNCZQENAX3oQ","updated_at":1691757017}

{"channels":["app_x_chatroom_1"],"created_at":1691757056,"id":"40c5a83e-55b7-4a62-a581-0dd23344a236","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiNDBjNWE4M2UtNTViNy00YTYyLWE1ODEtMGRkMjMzNDRhMjM2QDE2OTE3NTcwNTYiLCJ0aW1lc3RhbXAiOjE2OTE3NTcwNTZ9.tmLyhUA0LjfeXxKhSLRkTuq2VcjB5jO9nOh4GAk398g","updated_at":1691757056}

Beaver js client connection success

var id="8f38aa87-a388-4d67-b2cb-489a95f57bbb";
var token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiOGYzOGFhODctYTM4OC00ZDY3LWIyY2ItNDg5YTk1ZjU3YmJiQDE2OTE3NTcwMTciLCJ0aW1lc3RhbXAiOjE2OTE3NTcwMTd9.sQunm5HkSbsaW2aorHMEtNBGUyG39xVtNCZQENAX3oQ";

function Socket(url){
ws = new WebSocket(url);
ws.onmessage = function(e) {
console.log(e);
alert("onmessage");
document.getElementById("box").innerHTML+="
onmessage";
};
ws.onopen = function(e) {
console.log(e);
document.getElementById("box").innerHTML+="
onopen";
alert("open");
};
ws.onclose = function(){
// Try to reconnect in 5 seconds
document.getElementById("box").innerHTML+="
onclose";
alert("close");
setTimeout(function(){Socket(url)}, 5000);
};
}
Socket("ws://localhost:8080/ws/"+id+"/"+token);

publish message "hello444" to channel "app_x_chatroom_1" ok

but Beaver js client can not recieve any message.

log:
{"correlation_id":"29a8ad09-c62c-4555-aa2b-755ff9e010e3","http_status":200,"level":"info","msg":"Request finished","response_size":0,"time":"2023-08-11T20:53:41+08:00"}
[GIN] 2023/08/11 - 20:53:41 | 200 | 15m13s | 127.0.0.1 | GET "/ws/8f38aa87-a388-4d67-b2cb-489a95f57bbb/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiOGYzOGFhODctYTM4OC00ZDY3LWIyY2ItNDg5YTk1ZjU3YmJiQDE2OTE3NTcwMTciLCJ0aW1lc3RhbXAiOjE2OTE3NTcwMTd9.sQunm5HkSbsaW2aorHMEtNBGUyG39xVtNCZQENAX3oQ"
{"correlation_id":"5da5c750-5994-412e-832a-2290a88ae251","http_method":"GET","http_path":"/ws/8f38aa87-a388-4d67-b2cb-489a95f57bbb/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiOGYzOGFhODctYTM4OC00ZDY3LWIyY2ItNDg5YTk1ZjU3YmJiQDE2OTE3NTcwMTciLCJ0aW1lc3RhbXAiOjE2OTE3NTcwMTd9.sQunm5HkSbsaW2aorHMEtNBGUyG39xVtNCZQENAX3oQ","level":"info","msg":"Request started","request_body":"","time":"2023-08-11T20:53:41+08:00"}
{"level":"info","msg":"Redis connection established","time":"2023-08-11T20:53:41+08:00"}
{"level":"info","msg":"Client 8f38aa87-a388-4d67-b2cb-489a95f57bbb connected to all subscribed channels","time":"2023-08-11T20:53:41+08:00"}
{"level":"info","msg":"Client 8f38aa87-a388-4d67-b2cb-489a95f57bbb connected","time":"2023-08-11T20:53:41+08:00"}
{"correlation_id":"f8c0af4a-8f34-44c9-a93e-9e400b9ece26","http_method":"POST","http_path":"/api/publish","level":"info","msg":"Request started","request_body":"{"channel":"app_x_chatroom_1","data":"{\"message\":\"hello444\"}"}","time":"2023-08-11T20:54:04+08:00"}
{"level":"info","msg":"Redis connection established","time":"2023-08-11T20:54:04+08:00"}
{"correlation_id":"f8c0af4a-8f34-44c9-a93e-9e400b9ece26","level":"info","msg":"Collecting metrics","time":"2023-08-11T20:54:04+08:00"}
{"correlation_id":"f8c0af4a-8f34-44c9-a93e-9e400b9ece26","http_status":200,"level":"info","msg":"Request finished","response_size":-1,"time":"2023-08-11T20:54:04+08:00"}
[GIN] 2023/08/11 - 20:54:04 | 200 | 976.5μs | ::1 | POST "/api/publish"

It's solved, just I not use offical Redis,