Use TCP socket in React Native? - websocket

I want to create a TCP socket in React Native, connect to a telnet server with port of 23.
I found there has 'RCTWebSocket', but it seems only support http, https, ws, wss protocols, and always occurred error when remote response.
Is there a way to use TCP Socket which not only for http, ws protocols ?

You could try native objective c tcp socket with a js interface. Look for "extension " in the react native github page.

Related

Does http3/quic fall back to tls 1.2 if the browser doesn't support quic?

Even after lots of googling, I'm pretty naive about quic.
I'm specifically looking into lucasclemente/go-quic.
Should quic servers use 443? If so, will it fallback to http2 & tls 1.2?
I'm speaking generally. Not for that specific go package. But if you have specifics for that go package, that would be great.
Yes, I realize quic is still young and not necessary yet. I'm simply curious and couldn't find that specific answer. Thanks!
Quic servers can use any port they want; 443 is often used, but this is not necessary at all. Note we're talking about UDP ports, not TCP ports.
A QUIC server cannot fallback to HTTP2 or TLS 1.2, because if the client sends a QUIC request, the server can only respond with a QUIC response. If the browser doesn't support QUIC, it will not send a QUIC request in the first place, so there is no issue at all.
I think you are assuming that a QUIC server runs (or can run) on the same port as HTTPS and therefore has to generate either a QUIC or an HTTPS response; this is not the case, as QUIC is running over UDP, not over TCP (like HTTP and HTTPS do). TCP ports and UDP ports are different address spaces, so one can run an HTTPS server on tcp port 443 and simultaneously run another QUIC server on udp port 443.

Firewall blocks connection to second WebSocket server

In short we have two separate servers for our web app. The first one is the main server that uses Websockets for handling "chat rooms", and the second server only handles WebRTC audio chat rooms via Websocket. Both servers use Express to create a HTTPS server, use secure Websocket and the port 443.
I recently encountered a problem where a corporate client's firewall blocked the wss-connection to only the WebRTC server. The error logged in the user's browser was "ERR_CONNECTION_TIMED_OUT", which means the user never connects via Websocket. This has not happened with any other clients.
The Websocket connection works normally between the user and the main server, and no rules have been added to their firewall to use our app.
Has anyone encountered something similar? What kind of a firewall setting might cause this? Could this be a cors problem, since the servers are on their own sub-domains?
The main server could be restricting the type of data sent on port 443, which will use SSL to secure that transmitted data.
Refer to this page for information on the "Well-know port numbers".
The WebRTC audio data may need to be transmitted on its own dedicated port number that has been configured on the main server for this.
The problem was that the main server WebSocket used TCP and the WebRTC server used UDP, and UDP was blocked by corporate firewall on default.
WebRTC should use TCP as a backup, but I'm assuming UDP is still needed for the handshake.

MQTT over websocket in c

I have implemented mqtt using server connection tcp socket on my machine with mosquitto broker. I have totally understood the mqtt protocol and its frame format. I want to publish my data over webserver which supports mqtt over websocket.
How can I start with this thing?
I am not clear with websocket concept
Can I implement websocket using tcp or is there any other method.
do i have to use http to implement mqtt over web socket as to send data over webserver?
As http and mqtt use different methods to send or receive data.
I don't want to use ready libraries such as paho.
I am totally new to this socket programming.any help or guideline will greatly appreciated!!!
Websockets are an extension to the HTTP protocol, you need to use a correctly formatted HTTP request to setup a new Websocket connection.
Once the connection is setup it can be used to send the exact same binary MQTT packets that you would send over an existing TCP connection.
I suggest you look at using an existing library like libwebsockets to handle the Websocket connection setup, then you should be able to interface your existing code to just use the websocket handle instead of the socket handle.
If you REALLY don't want to use a library then you will need to start by reading the Websocket RFC https://www.rfc-editor.org/rfc/rfc6455

Can I use http port in telnet app on heroku?

I want to deploy my telnet app on heroku, but they allow to use only http traffic. Can I use http port as telnet port?
No, you cannot.
The heroku router will only be able to handle HTTP requests (with HTTP headers and a body), not all TCP connections.
This is not something Heroku can handle at the moment.

Monitoring secure web sockets (wss) with wireshark

I have an application that uses secure websockets that I am having trouble with.
I would like to use wireshark to debug the problem, however I can not figure out the correct parameters to put into wireshark to monitor and display a secure web socket connection using HTTPS.
Does anyone know of a wireshark filter that would accomplish what I need and if I need to do anything else to monitor secure websockets using wireshark?
If you want to monitor a WebSocket connection between the browser and a server, then it might be easiest to use the Chrome or Firefox developer tools.
The following applies to WebSockets using the HTTP/1.1, it might not work for WebSockets bootstrapped with HTTP/2 (RFC 8441).
The following steps describe the necessary steps for Wireshark 3.4.0, but it will likely work for newer versions as well.
Because secure WebSocket connections (URI scheme wss) tunnel the data over TLS, the general steps for decrypting TLS traffic with Wireshark apply, see the Wireshark wiki article.
Depending on your setup these steps and capturing of packets might have to be performed before the WebSocket server is started and before the connection to the client is established.
WebSockets use TCP for transmission, therefore you have to use a Wireshark display filter which only shows the relevant TCP segments.
For example if your WebSocket server is listening on port 443, you could use the following to show only incoming and outgoing packets to that port:
tcp.port == 443
If you performed the previous steps correctly and click on one of the TLS "Application data" packets, it should show a "Decrypted TLS" tab at the left bottom corner:
If you are using the well-known port 443, then Wireshark is able to detect the HTTP upgrade to WebSocket on its own.
However, if you are using a custom port, you have to tell Wireshark how to decode the packets. To do so right click on any of the packets and select "Decode As...":
In the new dialog, click on "(none)" in the "Current" column and select "HTTP" from the dropdown:
You should now see the HTTP upgrade to the WebSocket protocol and all of the WebSocket messages. Additionally you can inspect their content:

Resources