UDP connections from website - web

Is there any way to start a UDP connection from within a website?
So that users can connect to a server listening for UDP packets while being on my website?

If you have full control over the server and the web application running on the server it can be done. If you don't have such control firewall settings or other kind of restrictions you don't control might limit what you can do.

Related

How to bind a service into any host's port?

Hello, 👋
I was wondering how services (like mysql, apache, mongoDB) are bind against a port in the server/local machine. How does this work?
I'm guessing that when the service starts, it tries to connect to the port and if possible, the service is "paused" until the OS receives a request against the selected port. Is there any documentation out explaining how this works?
Thank you!
May I help you?
This is a list of TCP and UDP port numbers used by protocols for operation of network applications.
The Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP) only need one port for duplex, bidirectional traffic. They usually use port numbers that match the services of the corresponding TCP or UDP implementation, if they exist.

How to have both HTTP and TCP server on Heroku

I intend to deploy a nodejs app on Heroku which is both an HTTP and TCP server. I can see that I can map my application to a routed port using process.env.PORT. However, this would be just one port, yes? I couldn't map both my HTTP server and TCP server to the same port. Is there a way that I can do this, possibly by getting a second routed port?
Please note, my TCP client applications are not necessarily going to be nodejs (probably Python), so I need something lower level than socket.io and websockets. I was going to use net.
TCP and HTTP are in different layers.
HTTP is under the Application Layer.
TCP is under the Transportation Layer.
An HTTP client initiates a request by establishing a Transmission Control Protocol (TCP) connection to a particular port on a server (typically port 80).
In computer networks, every application is getting/asking from the operating system a port that it can listen to.
If you have 2 TCP servers- one is HTTP server and the other one is another server, they can't listen to the same port, unless you have two NI because of the TCP protocol operations.

What if 5222 port/domain is blocked for Xmpp

I have a java Client(Smack API) connecting Openfire server which listens at port 5222.
In one of the deployement scenarios the firewall has blocked 5222(tcp xmpp client communication). Tried using BOSH(Blabber library) , but its not able to handle the load. Whats the solution for this scenario?
I read that even Gtalk uses 5222 but if the network firewall blocks it, they are able to connect seamlessly thru 443 or port 80. How does it work? whats the protocol being used.
If 5222 is blocked, xmpp client over insecure connexions can't connect to your server.
But BOSH is listening over the port 7070 with connect (7070 for unsecure connexion)
In other case, you can post the logs

WebSocket hosted not in port 80 firewall issues

A websocket server that is not hosted in port 80, will be invisible from Internet Browsers?
I cannot use port 80 (it's being used by IIS) neither 443 nor 8080.
Does websockets hosted on custom ports will have firewall issues?
The only way is to use IIS8 as to share the same port (80)?
(I'm using IIS7 with SuperWebSocket library)
Websockets that are accessed from browsers, should not be deployed in custom ports?
Thanks in advance.
To get to the heart of your question, I've had most success with realizing that my Web Server and Web Socket Server can both be on port 80, but different hosts ( origins ). As long as the Web Socket Server can handle CORS requests from your Web Page origin, it seems this is a way that avoids firewall problems and leads towards the architecture of having static content froma Web Server and dynamic from a WebSocket server.
So the story is:
serve page from web.server.com:80 (that's the origin)
in application space on that web page open a WebSocket to websocket.server.com:80/serviceName
(makes a cross-origin request that needs be be allowed by websocket.server.com, which might whitelist web.server.com)
happily serve dynamic content and static content separately.
Some more specific answers to some of your questions:
A WebSocket server that is not hosted in port 80, will be invisible from Internet Browsers?
No. Your application in the browser can open a WebSocket to other ports if that is desirable,
subject to CORS constraints. Oftentimes it is advantageous to keep the WebSockets on port 80, so that intermediaries and edge gateways don't have to change firewall rules.
I cannot use port 80 (it's being used by IIS) neither 443 nor 8080.
Does WebSockets hosted on custom ports will have firewall issues?
Most likely, unless you are in control of the firewall and can open up other ports.
If you have control over the firewall then there is no issue with running a websocket server on a custom port. You just need to open up the port to allow incoming traffic to that port.
The problem is not really firewalls per se but rather other types of filtering, proxying, load balancing, etc that happens before the traffic reaches your server. However, unless you have specific requirements that you didn't mention then there should be no issue with simply allowing traffic on that port.
If you WebSocket server is configured to limit connections to specific origins (CORS) then you will need to allow the origin to make connections. The origin is the address of the web server that will be serving up the web page that will make the WebSocket request. The default is usually either wide open or limited to the address of the websocket server itself.
According to here:
Warning: The server may listen on any port it chooses, but if it
chooses any port other than 80 or 443, it may have problems with
firewalls and/or proxies. Connections on port 443 tend to succeed more
often but of course, that requires a secure connection (TLS/SSL).
Also, note that most browsers (notably Firefox 8+) do not allow
connections to insecure WebSocket servers from secure pages.

How to handle TCP long connection when one server fail?

I have many linux servers (cluster) to run my application.The application use C/S structure,client connect to server using TCP long connection(server is basing apache mina socket framework).
my question is : When one server shutdown, how other servers can keep the socket connection established between the failure server and the clients?
so the server-down failure can be transparent to clients and clients need not reconnect to server.
Thanks
L.J.W
You cannot simply migrate a TCP connection unless there is some kind of never-failing proxy in between like a layer-4-switch.

Resources