websocket

tomcat websocket servlet listening port

妖精的绣舞 提交于 2021-02-09 20:43:37
问题 I'm trying to write a servlet that uses org.apache.catalina.websocket.WebSocketServlet . I've found an example of websocket chat, but I can't figure out how can I specify the listening port for a websocket server (which is implemented in this servlet)? For example I need to listen for clients connection on port 11337 . But how I can express this? OK, here is the (simplified) code: public class TestServlet extends WebSocketServlet { private static final Logger logger = LoggerFactory.getLogger

tomcat websocket servlet listening port

泪湿孤枕 提交于 2021-02-09 20:43:08
问题 I'm trying to write a servlet that uses org.apache.catalina.websocket.WebSocketServlet . I've found an example of websocket chat, but I can't figure out how can I specify the listening port for a websocket server (which is implemented in this servlet)? For example I need to listen for clients connection on port 11337 . But how I can express this? OK, here is the (simplified) code: public class TestServlet extends WebSocketServlet { private static final Logger logger = LoggerFactory.getLogger

Singleton Websockets object with different callback handlers

£可爱£侵袭症+ 提交于 2021-02-08 13:08:05
问题 I have a JavaScript Websockets implementation where I would like to use a singleton model that uses one Websocket connection for multiple calls to the server but with different callback event handlers. I have the implementation working just fine but have noticed some strange behaviors with messages being directed to the wrong callback handler. Here is some code: Connection.js file var connection = function(){ var _socket = null; return { socket : function(){ if (_socket == null){ _socket =

Singleton Websockets object with different callback handlers

隐身守侯 提交于 2021-02-08 13:03:47
问题 I have a JavaScript Websockets implementation where I would like to use a singleton model that uses one Websocket connection for multiple calls to the server but with different callback event handlers. I have the implementation working just fine but have noticed some strange behaviors with messages being directed to the wrong callback handler. Here is some code: Connection.js file var connection = function(){ var _socket = null; return { socket : function(){ if (_socket == null){ _socket =

Send output of popen through websockets

一曲冷凌霜 提交于 2021-02-08 12:17:58
问题 I'm using popen with fgets to read the output of tcpdump asynchronously. The below code should be run in the command line, not with apache and viewing it in your browser. $handle = popen('tcpdump -nnX', 'r'); while (true) { $output = fgets($handle); print $output . "\n"; } The problem arises when I try to output this information via websockets. Websockets also use an infinite loop (for managing its sockets, ticks, and messages). It looks something like: while (true) { @socket_select($read,

Connecting and sending message between Spring WebSocket instances

柔情痞子 提交于 2021-02-08 10:48:32
问题 I have multiple instances using Spring Boot WebSocket (created following the first half of Spring's guide). I need them to connect to other instances at specific hostnames and ports and to be able to send messages over the websocket connection using STOMP protocol. How can I connect to my other services over websocket? How can I send messages using the STOMP protocol (preferably using the same marshalling/unmarshalling magic I get with received messages)? Things that don't answer my question:

Syntax error on new WebSocket in edge, internet explorer

一个人想着一个人 提交于 2021-02-08 10:30:49
问题 So I think I am getting crazy. I use javaScript to make a WebSocket connection on port 443. The problem is that the WebSocket declaration is throwing a SyntaxError only on edge and internet explorer browsers, on other browsers like Chrome and Firefox it works perfectly. The code that I use: var Connection; Connection = new WebSocket("ws:/127.0.0.1:443"); Does someone knows what am I doing wrong? 回答1: change it to: var connection = new WebSocket("ws://127.0.0.1:443"); 回答2: This issue comes

Syntax error on new WebSocket in edge, internet explorer

陌路散爱 提交于 2021-02-08 10:30:04
问题 So I think I am getting crazy. I use javaScript to make a WebSocket connection on port 443. The problem is that the WebSocket declaration is throwing a SyntaxError only on edge and internet explorer browsers, on other browsers like Chrome and Firefox it works perfectly. The code that I use: var Connection; Connection = new WebSocket("ws:/127.0.0.1:443"); Does someone knows what am I doing wrong? 回答1: change it to: var connection = new WebSocket("ws://127.0.0.1:443"); 回答2: This issue comes

Docker nginx websocket proxy== client closed connection while waiting for request

孤街醉人 提交于 2021-02-08 10:14:33
问题 I desperately trying to setup nginx proxy to websocket. Websocket connects but then I'm getting 2018/02/10 19:30:34 [info] 7#7: *238 client closed connection while waiting for request, client: 172.18.0.1, server: 0.0.0.0:8888 Here's the minimal example: nginx.conf worker_processes 1; events { worker_connections 1024; } error_log /dev/stdout debug; http { resolver 127.0.0.11 ipv6=off; include mime.types; access_log /dev/stdout; default_type application/octet-stream; sendfile on; keepalive

How to send a message through web socket to a connected user?

ぐ巨炮叔叔 提交于 2021-02-08 10:13:03
问题 I want to send a message through a web socket to a specific user. So far I can open a web socket and read message from client like that: @ServerEndpoint(value = "/wsep") public class WebSocketEndpoint { private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketEndpoint.class); private Session session; @OnOpen public void onOpen(Session session) { this.session = session; try { session.getBasicRemote().sendText("You are connected. Your ID is " + session.getId()); } catch (Exception