Spring 4 WebSocket configure port - spring-mvc

Using Spring 4 I need configure WebSocket use other port than HTTP.
In other words by default user access to HTTP and WebSocket as follow:
http://server:9090/
ws://server:9090/
But I need do the follow:
http://server:9090/
ws://server:9999/
In code I have only following:
#Configuration
#EnableWebSocket
public class WebSocketConfig
implements WebSocketConfigurer {
Also I have Handler:
Handler extends TextWebSocketHandler {
Is there such ability in Spring?

AFAIK all current implementations of websockets depend on a handshake via HTTP. After the handshake the existing connection is upgraded. You don't get a new one and the port stays the same. Basically all websocket connections start as HTTP connections.
As a side note the ports, IP addresses etc. are subject of the server, not the application itself.
It might be possible to configure your server so that two ports can be used for an application, but they would both be used for HTTP and websocket alike. On the other hand this might be useful in your situation.

Spring WebSocket different port for ws:// protocol
Due to limitation and in order to use websockets on App Engine Flexible Environment, app need to connect directly to application instance using the instance's public external IP. This IP can be obtained from the metadata server.
All MVC/Rest (http://) call should still serve from 8080 and in App Engine Flexible Environment ws:// server from ws://external_ip:65080
working code
https://github.com/kevendra/springmvc-websocket-sample
http://localhost:8080/
ws://localhost:8080/
to work with App Engine need below
http://localhost:8080/
ws://localhost:65080/ - in local
ws://external_ip:65080/ - App engine
Ref:
Extends org.eclipse.jetty.websocket.server.WebSocketHandler and start server context to 65080, but I'm looking for server managed by spring
How do I create an embedded WebSocket server Jetty 9?
Spring 4 WebSocket Remote Broker configuration

Related

C# gRPC client - name resolution failure

A client is running our C# gRPC client on a corporate network, behind an HTTP proxy. The http_proxy environment variable is configured, but nevertheless he sees an error message Name resolution failure when attempting to connect to the server on the internet.
DNS resolution from the same machine works fine using nslookup.
Any ideas what I can do to investigate this problem?
You can use the following three lines at application startup to configure the detailed logging that #JanTattermusch suggested:
Environment.SetEnvironmentVariable("GRPC_TRACE", "api");
Environment.SetEnvironmentVariable("GRPC_VERBOSITY", "debug");
Grpc.Core.GrpcEnvironment.SetLogger(new Grpc.Core.Logging.ConsoleLogger());
In order to connect a C# gRPC client on a corporate network, behind an HTTP proxy, add this on the client main method works:
Environment.SetEnvironmentVariable("NO_PROXY", "127.0.0.1");

SignalR port requirement

I haven't found much discussion about this...
Most signalr samples I have seen would send and receive via a designated port like 5000 or 8080
I have a need for chatting in my app. My asp.net backend site does more than just handling messages between users, so it doesn't make a difference for me to host another page for that in the site my iis.
I understand the difference of having the signalr self-hosted or hosted normally in iis... If I have it hosted by iis, so my users will access the page normally without a port, would that make a difference? Is there something internal in signalr that is preferring the use of a port? What are the pros/cons of using ports with signalr?
SignalR has no preference for a specific port. When no port in specified in the URL then the port is implied from the protocol, e.g. HTTP uses port 80 and HTTPS uses port 443. So there is no concept of SignalR without a port.
I would think that the main reason for using SignalR on a different port than the rest of your site is that you can host SignalR independently of your main site without any interference in URL's etc. On the other hand, using a non-standard port may give you problems with restrictive firewalls that only allows traffic on port 80 and 443 to pass. When using a different port for SignalR you also lose the ability to use relative URL's to specify the SignalR endpoint.

Running a federated RabbitMQ on port 80

Our client has a requirement that a web server can only have port 80 and 443 open, both public and internal facing, but our application would benefit from using queuing on the inside.
Is it possible to run RabbitMQ over port 80?
Update
The setup is as follows.
We have a public facing API server which calls various back end systems.
In between the API server and the back end servers there is another layer which in most cases just works like a proxy.
Some of the back end systems, as well as the proxy layer, go up and down intermittently.
What I would like to do is have a queue on the API server, a queue in the proxy layer and a queue in the back end layer.
These queues would be federated so that a messages placed on the queue on the API server would be forwarded all the way down to the back end servers (queuing is needed for inserts and updates only).
One way is using Web-Stomp plugin and Sock.js, using nginx as proxy.
Another way - node.js callback for some sending messages, handling events and create messages with node.js.
Server side works with RabbitMQ by localhost connect with default port.
Third way is using subdomain with another IP adress.

Access a private web server using static IP from Android Application

I want to access an Oracle web service in my Android application. But the web service is on my company's server so the public cannot access it. But our Android app is going to be used by the public. Is there a way to use that web service and connect to the server without changing the server's security configurations..? Thank you very much.
you can either try tunneling through a web server as is a standard industry practice. Setup a pair of web server in front of oracle app servers and then a load balancer if front of webs servers. The firewall can be configured to allow traffic on ports 80 (standard http port) or 443 (standard https port). Everything below the load balancer stays protected inside the firewall and you wont have to tweak your oracle server for security configuration changes.

How can I use SignalR Hubs / Proxies without SignalR connection?

Here is my situation:
I have a 4-tier web application consisting of browser, web server, application servers and database.
Browser and application server should communicate in a RPC-style way.
The backend will run on windows machines, so I will use IIS as web server The application needs real time communication between application server and browser.
I want to use a SignalR connection for the communication between browser and web server. For the communication between web server and application server's I want to use a plain TCP connection.
I think this approach will enable me to send JSON messages between browser and application servers. But how can I realize a RPC communication?
Can I write a SignalR Hub, generate a JS proxy and bind the Hub to a TCP socket?
Here is a picture: https://www.dropbox.com/s/xeaja4dos4bgvbz/SignalR_Hubs_Stackoverflow.png
Nope. SignalR is based on HTTP not TCP directly. WebSockets is the closest thing to a raw tcp socket and it has the added benefit that it works over port 80.

Resources