chrome.devtools.network.getHAR doesn't retrieve WebSocket Messages - google-chrome-extension

I need to retrieve WebSocket messages and I was planning to create a Chrome Extension which could do that by using chrome.devtools.network.getHAR for example.
But unfortunately it doesn't retrieve Messages or Frames sent via WebSocket.
Is it any solution available on how to retrieve WebSocket Messages / Frames?
This is what I am trying to retrieve (using https://www.websocket.org/echo.html):
This is the code I use:
But no Frames data can be retrieved:
Thank you for any suggestions in advance!

Related

Sending updated messages to Socket Server using selectors library

I have followed a tutorial on Python Sockets and trying to modify the client side to send updated data but in vain. The source code of the tutorial can be found here. The problem is I am not able to understand how to send updated message with Python selectors after registering the connection. The example I am trying to modify is:
Server works fine.
Client Here I want to send data continously at runtime.
Here in the example two messages are sent from the client side but they are defined at time of registering the connection but what I want to do is to send updated data at runtime.
I have tried to modify the object by using modify method from the selectors library but that didn't worked.
One idea I am having is to trigger a write event from client side after updating the message but how to do so I am not able to find also after spending quite some time.
Any ideas on how to send updated messages at runtime using selectors will highly be appreciated.
Edit 01
From server and client side this and this line needs to be commented out to prevent connection close after first message

Multiple websockets on same page

Can I have multiple websockets on a single webpage? I want to implement a real time chat application just like facebook. Also can you please tell how facebook handles multiple users chats at the same time ? Whether only one websocket is being opened for chat or multiple websockets are opened and configuration is done on server side ?
Just googled many areas and got to the conclusion that we must implement one websocket in one webpage & can send more data which help in identifying what type of message & to whom it must be delivered like in my case I can send sender's name and receiver's name with that message to the backend server with the only websocket opened accordingly.
We can also have multiple websockets on one page but it is not recommended

Send JSON and blob together

I'm writing a simple streaming service.
A browser An open a web socket to a server, then another browser B open a new socket to the same server.
Browser A register a video by its camera (MediaRecorder API) and send it to the server.
The server broadcast this video to others connected browsers.
I have a working version with Socket.IO, but I'd like to do it in vanilla JavaScript (WebSocket.Server on Node.js server and webSocket on client).
This is the problem:
With socket.io a can write something like this:
this.socket.emit('broadcast', {
stream: new Blob(stream, {'type': `video/webm${MEDIA_CHARSET}`}),
from: {id: this.socket.id}
});
Stream comes from mediarecorder -> dataavailable event listener
But with native websocket I can't send blob embed in a JSON object, because websocket can send only string or arraybuffer.
I tried many different ways in order to send JSON and blob together, but nothing works.
Any help?
Is it possible to use only Engine.IO on client side in order to pack a message with blob and JSON together? Any ideas about this way?
There are many ways to serialize your data for sending over a binary web socket. I would recommend considering CBOR, which serializes to binary and also has support for binary data within it.
There are several CBOR libraries to choose from on NPM.

Display data received through GRPC client on web page

I'm new in the GRPC world.
I need to display the data produced by some GRPC server on a webpage.
So I created a nodejs client to receive the stream of data which is working fine, but I need to show the results on a webpage and I have no idea how to do so.
Any help would be welcome
You can try to use the beta grpc-web https://github.com/grpc/grpc-web to access the gRPC service from the web. This works by setting up a gateway in the middle as per the grpc-web documentation.

send Session Description from node server to client

Do I need to use a websocket to send JSON data to my client? (it's a tiny session description)
Currently my client-side code sends a session description via XHR to my Node.js server. After receipt, my node server needs to send this down to the other client in the 'room'.
I can achieve this using socket.io, but is it possible to do anything a bit faster/ more secure, like XHR for example?
If you just want to receive the offer from the other side and nothing else, I would suggest you to try HTML5 Server Sent Events.
But this may bring problems due to different browsers support, so I would use a simple long pooling request. Since you only want to get the SDP offer, the implementation is pretty simple.
No, you don't need to use the WebSocket API to send JSON data from client to client via a server, but unless you use Google's proprietary App Engine Channel APIs, then the WebSocket API is probably your best choice.
Also, please keep in mind that you're not only sending session descriptions, but also candidate info (multiple times) as well as other arbitrary data that you might need to start/close sessions, etc.
As far as I know, the WebSocket API is the fastest solution (faster than XHR) for signalling because all the overhead involved with multiple HTTP requests is non-existent after the initial handshake.
If you want to code things yourself, I'd start reading the latest WebSocket draft and learning how to code the WebSocket server-side script yourself or else you will pretty much have to rely on a WebSocket library like Socket.IO or a proprietary solution like Google's App Engine Channel APIs.
How about using the 303 HTTP status code?
The first client send the session description to resource X, the server acknowledges the receipt and responds with a 303 status code that points to a newly created resource Y that accumulates other clients session descriptions.
The first client polls resource X until it changes.
The second client send its session description to resource A, the server acknowledges the receipt and updates resource Y. The first client notices the update with the next poll and will now have the second client's session information.

Resources