can not show messages received in console with pusher and websocket - laravel

for project i used pusher to create realtime chat using laravel 9 . i can send message from front end to backend with api but can not received messages from backend
chat channel created but won't show up anything
for example when an event called backend completely received that but could not send anything or can not connect to channel
js :
Echo.channel('chat').listen('.MyMessage', (e) => {
console.log(e)
})
could anyone help me ?

Related

How Can I listen or subscribe to pusher:pong event using Vue pusher echo?

I'm using the Vue + Laravel pusher in my Realtime app.
I realized that client sends "pusher:ping" event to backend and it responds with "pusher:pong" based on Doc.
I was wondering how can I detect if the socket connection is alive?
Is there a way to subscribe or listen to the protocol level events?
Thanks

Send Slack Modal Data to Third Party

Is it possible to send data gathered from a Slack modal to an external site?
I’m using Slack Bolt for JavaScript
I’ve tried receiver.router.post('siteToSendData', (req, res) => { // You're working with an express req and res now. console.log('post to slack') res.send(dataToSend); });
You cannot send the captured data directly to a third party site. What you can do instead, is process the submission event.
https://api.slack.com/surfaces/modals/using#handling_submissions
Slack Bolt Reference : https://slack.dev/bolt-js/concepts#view_submissions
The captured data will be sent to your application first. You can then re-route it to the desired external website.
Here is example of payload that you can expect: https://api.slack.com/reference/interaction-payloads/views

Pusher sending event is not showing in console

I am trying to show pusher sending event for showing in my console. But it giving empty in my console.though send info. from my browser to pusher is working, but sending event from pusher is not working.
i have filled up all info in my laravel project file, like PUSHER_APP_ID,PUSHER_APP_KEY etc, but sending from browser is working, but receiving event from pusher is not working.any help....

Multiple user sessions not receiving subscription message - spring stomp websocket

I am using Spring stomp websocket framework to send subscription messages to the clients. We are using ActiveMQ as the message broker
and is using a stomp javascript client. Spring 4.1.5 and In this architecture, the messages are sent using
simplemessagingTemplate.convertAndSendToUser(user, "/queue/msg", serverMsg, map);
In order to ensure that only the right user receive their message, I am also making use of a QueueSubscriptionInterceptor that implements ChannelInterceptor.
The messages are delivered to the destination correctly. The messages are received using the JS client like this.
stompClient.subscribe('/user/guest/queue/msg', function(greeting){
x = JSON.parse(greeting.body);
...
}
So far so good. However, when there are multiple user session, only one session receives the message. For (e.g), if two "guest" users
are logged in, I would like all the two "guest" users to receive the message. This doesnt seem to be happening. Looking into the logs,
I see that the message seems to be sent..
2015-04-11 14:39:40 DEBUG StompBrokerRelayMessageHandler:738 - Forwarding SEND /queue/msg-user1 session=_system_ application/json;charset=UTF-8 payload={"my message to you...)
2015-04-11 14:39:40 DEBUG StompBrokerRelayMessageHandler:738 - Forwarding SEND /queue/msg-user0 session=_system_ application/json;charset=UTF-8 payload={"my message to you...)
I see only one client receiving the message and not the other. Reading the Spring documentation, I understand that this is the default behaviour.
Can someone tell me what I am doing wrong.
Thanks.
You should use the semantic of topics instead of queues.
A queue allows the message to be consumed once, but a topic will allow it to be consumed once per subscriber. So something like /topic/user/guest/msg probably would do it.
Set the ack header in the connect frame. What this will do is that the server will continue to send you the same message until you send back an ack frame. Which I am doing below by calling greeting.ack() as soon as receive the message. Setting it to 'client-individual' will mean that the server has to receive ack from all sessions of the particular client or it will keep re sending the same msg on every CONNECT.
Hope this helps!!
Use below code for reference.
function connect() {
var socket = new SockJS('/powerme-notification-websocket');
stompClient = Stomp.over(socket);
stompClient.connect(
{client_id:'testClient'}, function (frame) {
setConnected(true);
console.log('Connected: ' + frame);
stompClient.subscribe('/user/topic/releaseLock', function (greeting) {
stompClient.subscribe('/queue/releaseLock-testClient', function (greeting) {
console.log(greeting);
showGreeting(greeting.body);
greeting.ack();
},{durable:true,
'auto-delete':false,
ack:'client-individual',
id:'testClient'});
});
}
References:
https://stomp.github.io/stomp-specification-1.2.html#ACK

sails.js + socket.io: Can't receive standard sail.js/socket.io messages on client

With the newest beta version from sails.js (0.10.0-rc5) I'm trying to do this:
sails new Test
cd Test
sails generate api user
Create file assets/js/test.js
var socket = io.connect('http://localhost:1337');
socket.on('connect',function() {
console.log('connected');
socket.request('/user',{}, function(users) {
console.log(users);
});
socket.on('message', function(msg) {
console.log("Message: " + msg);
});
socket.on('user', function(msg) {
console.log("User: " + msg);
});
});
My problem
console.log("User: " + msg); and console.log("Message: " + msg); aren't receiving any messages when I create or update a user.
According to the documentation and to the Intro to sails.js video this socket.io messages should be send automatically.
What am I missing to successfully receive sails.js/socket.io message on my client?
If you installed the latest NPM version, then you'll also have the latest version of the Sails socket client. Check out its page on Github for basic usage, then check out the PubSub section of the Sails migration guide, which explains the differences between Sails v0.9.9x (which the Intro to Sails.js video shows) and the latest version. In the end, your code should look more like:
// Note--the latest sails socket client connects automatically!
// Get all of the existing users--also subscribes to socket events
// for those users
io.socket.get('/user', function serverResponded (body, sailsResponseObject) {
console.log(body);
});
// When a socket message about a user is received, display it
io.socket.on('user', function(data) {
console.log(data);
});
Notes
Pay special attention to the section in the migration guide about .watch(); it means that you don't get create events automatically anymore and have to subscribe to them in your server code using (for the User model) User.watch().
Remember that in general you don't get socket messages about actions that you yourself trigger, so if you want to test that your message-handling code is working, it's best to open up two windows (or tabs) and do your requests in one while watching for events in the other.
Also remember that you only get subscribed to socket events when you make a socket request; an AJAX call to /users will retrieve all of the current users, but you won't be subscribed to events. It has to be done using io.socket.get.

Resources