AW: WebSockets and HTTPS problems
Hi Check to see if the WebSocket examples that ship with Tomcat work with your configuration. If they don't compare the differences between the default configuration and you configuration to and find the change that breaks stuff. First, thanks for the reply. I downloaded tomcat 7.0.32 again and replaced the connectors in the configuration with my own (minus the executor references). Nothing else was changed. The WebSocket chat example works with http on port 80, but not on port 8443. It says: Info: WebSocket connection opened. * Guest3 has joined. And as soon as I send something: Info: WebSocket closed. The message does not get back to the client. So the problem must in my connector configuration: Connector port=80 protocol=org.apache.coyote.http11.Http11NioProtocol connectionTimeout=2 redirectPort=443 / Connector port=8443 protocol=org.apache.coyote.http11.Http11NioProtocol SSLEnabled=true scheme=https secure=true clientAuth=false sslProtocol=TLS connectionTimeout=2 keystoreFile=../https.p12 keystorePass=XXX keystoreType=PKCS12 URIEncoding=UTF-8 / I don't see it; how can this happen? What can I do to debug this any further? Best regards, Steffen smime.p7s Description: S/MIME cryptographic signature
Re: AW: WebSockets and HTTPS problems
On 10/10/2012 17:41, Steffen Heil (Mailinglisten) wrote: Hi Check to see if the WebSocket examples that ship with Tomcat work with your configuration. If they don't compare the differences between the default configuration and you configuration to and find the change that breaks stuff. First, thanks for the reply. I downloaded tomcat 7.0.32 again and replaced the connectors in the configuration with my own (minus the executor references). Nothing else was changed. The WebSocket chat example works with http on port 80, but not on port 8443. It says: Info: WebSocket connection opened. * Guest3 has joined. And as soon as I send something: Info: WebSocket closed. The message does not get back to the client. So the problem must in my connector configuration: I just took a look at this. The examples work out of the box for HTTPS with BIO but not with NIO. This looks like a Tomcat bug at this point. I'll take a look. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
AW: AW: WebSockets and HTTPS problems
Hi I just took a look at this. The examples work out of the box for HTTPS with BIO but not with NIO. This looks like a Tomcat bug at this point. I'll take a look. What would I need to do to switch to BIO for now? And does Comet work with BIO? Regards, Steffen smime.p7s Description: S/MIME cryptographic signature
Re: AW: AW: WebSockets and HTTPS problems
On 10/10/2012 19:51, Steffen Heil (Mailinglisten) wrote: Hi I just took a look at this. The examples work out of the box for HTTPS with BIO but not with NIO. This looks like a Tomcat bug at this point. I'll take a look. What would I need to do to switch to BIO for now? Change the protocol attribute for your connector. See the docs. And does Comet work with BIO? No, but APR does. ( I haven't tested APR, HTTPS and WebSocket yet). If you can hang on for a few hours, I might have a fix for you. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Sending through WebSockets
Hi I have a server with several websocket connections. (Or at least I will have at some time, see thread about ssl problems...) Now just as in the chat example, I need to send some data from time to time so some (but not neccessarily all) of those connections. Now, what happens if one of the clients stalls? I suspect the server sending buffer will fill up and the server will eventually block sending to that connection. Is there a way to prevent this? Can I detect if a sending buffer is full? Can I set its size? Can I register a notification to be notified when there is space in the sending buffer? Best regards, Steffen smime.p7s Description: S/MIME cryptographic signature
websockets: how to support most browsers that are using old version of websocket protocol
While latest websocket protocol is supported in Tomcat, a lot of browsers out there are using older versions of the protocol. It may take them years to phase out. Considering this, I also need to support older protocol versions. I am not sure how to do this. One route is I install jwebsocket. I am wondering if there is an easier way to make WebSocketServlet support older protocols. thanks - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
websockets wss:// protocol gives error...
I am able to connect from browser to tomcat using non secure WS connection: ws://127.0.0.1:8080/Myserver If I switch the connection string to secure protocol ws://127.0.0.1:8080/Myserver I get following error. Can somebody confirm if this has been implemented/known to work? I am using tomcat 7.0.27 thanks java.lang.IllegalArgumentException: Invalid character (CR or LF) found in method name at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:128) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:926) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: websockets wss:// protocol gives error...
On 16/06/2012 20:28, Ravi wrote: I am able to connect from browser to tomcat using non secure WS connection: ws://127.0.0.1:8080/Myserver If I switch the connection string to secure protocol ws://127.0.0.1:8080/Myserver That is neither the correct protocol nor the correct port. I get following error. Can somebody confirm if this has been implemented/known to work? I am using tomcat 7.0.27 Yes, it has been implemented. Yes, it works. The current examples need a few small tweaks to get them working with the secure protocol. I'll do that shortly. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: websockets wss:// protocol gives error...
Thank you Mark for pointing out the mistake. Following url works wss://127.0.0.1:8443/Myserver On 6/16/2012 2:32 PM, Mark Thomas wrote: On 16/06/2012 20:28, Ravi wrote: I am able to connect from browser to tomcat using non secure WS connection: ws://127.0.0.1:8080/Myserver If I switch the connection string to secure protocol ws://127.0.0.1:8080/Myserver That is neither the correct protocol nor the correct port. I get following error. Can somebody confirm if this has been implemented/known to work? I am using tomcat 7.0.27 Yes, it has been implemented. Yes, it works. The current examples need a few small tweaks to get them working with the secure protocol. I'll do that shortly. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: non blocking Websockets?
thank you mark. that was a great answer. Am 03.06.2012 22:49, schrieb Mark Thomas: On 03/06/2012 21:26, Christian Finckler wrote: Am 03.06.2012 19:50, schrieb Mark Thomas: On 31/05/2012 18:45, Christian Finckler wrote: Am 31.05.2012 11:09, schrieb Mark Thomas: On 31/05/2012 10:02, Christian Finckler wrote: Hello, as far I understood, the websocket implementation of tomcat is using one thread per client. Is there also a possibility to configure it to use non blocking IO? No. That has not yet been implemented. It shouldn't be too hard provided that non-blocking is used between messages and blocking is used during messages. Obviously, the BIO connector will always use blocking. Whoops. My bad. I implemented this already. NIO and APR/native will be non-blocking between messages and have been since the first Tomcat release to include WebSocket support. Note that all connectors will block between the point the upgrade is started and the first message is sent. This was on my to-do list for a while and I simply forgot I had actually implemented. Had I looked at the code first (like I just did) it would have been clear that this was implemented. Sorry for the mis-information. Mark Hello Mark, you have confused me a bit. So there isn't one thread for each websocket client used? For the BIO connector it is always one thread== one connection. You cannot do non-blocking IO with the blocking IO connector. For NIO and APR/native is: - as many connections as you like up to maxConnections - one thread== WebSocket frame The threads are taken from the connector's connection pool and are returned once the WebSocket frame has been read. Reads are non-blocking between frames but blocking during a frame (to save having track detailed state between reads) Writes are always blocking. In short, if the client isn't sending any data, Tomcat doesn't allocate a thread to read it. The poller monitors the connection and passes it to a thread when there is a message to read. If not. What are the configuration possibilities for that? maxThreads, maxConnections on the connector just like HTTP. And how to do it? Use the NIO or APR/native connector and it just works. Perhaps you can describe more deeply how you handle websockets in regard of blocking/non blocking and thread handling? See above. If you want more detail, look at the source code. I am not going to translate that into pseudo code for you. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: non blocking Websockets?
On 31/05/2012 18:45, Christian Finckler wrote: Am 31.05.2012 11:09, schrieb Mark Thomas: On 31/05/2012 10:02, Christian Finckler wrote: Hello, as far I understood, the websocket implementation of tomcat is using one thread per client. Is there also a possibility to configure it to use non blocking IO? No. That has not yet been implemented. It shouldn't be too hard provided that non-blocking is used between messages and blocking is used during messages. Obviously, the BIO connector will always use blocking. Whoops. My bad. I implemented this already. NIO and APR/native will be non-blocking between messages and have been since the first Tomcat release to include WebSocket support. Note that all connectors will block between the point the upgrade is started and the first message is sent. This was on my to-do list for a while and I simply forgot I had actually implemented. Had I looked at the code first (like I just did) it would have been clear that this was implemented. Sorry for the mis-information. Mark Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org Ok, if that is so easy, it should be done. I am developing an online game, in which the player dont send messages very often (max: ten messages per minute), but is is very important to get the messages of other players very fast. Thats why I want to use websockets. But now it would be sad, if I need multiple tomcat instances only for connection handling although the process handling itself is not very complicated (cpu and memory intensive). Thank you, Chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: non blocking Websockets?
Am 03.06.2012 19:50, schrieb Mark Thomas: On 31/05/2012 18:45, Christian Finckler wrote: Am 31.05.2012 11:09, schrieb Mark Thomas: On 31/05/2012 10:02, Christian Finckler wrote: Hello, as far I understood, the websocket implementation of tomcat is using one thread per client. Is there also a possibility to configure it to use non blocking IO? No. That has not yet been implemented. It shouldn't be too hard provided that non-blocking is used between messages and blocking is used during messages. Obviously, the BIO connector will always use blocking. Whoops. My bad. I implemented this already. NIO and APR/native will be non-blocking between messages and have been since the first Tomcat release to include WebSocket support. Note that all connectors will block between the point the upgrade is started and the first message is sent. This was on my to-do list for a while and I simply forgot I had actually implemented. Had I looked at the code first (like I just did) it would have been clear that this was implemented. Sorry for the mis-information. Mark Hello Mark, you have confused me a bit. So there isn't one thread for each websocket client used? If not. What are the configuration possibilities for that? And how to do it? Perhaps you can describe more deeply how you handle websockets in regard of blocking/non blocking and thread handling? Thank you, Chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: non blocking Websockets?
On 03/06/2012 21:26, Christian Finckler wrote: Am 03.06.2012 19:50, schrieb Mark Thomas: On 31/05/2012 18:45, Christian Finckler wrote: Am 31.05.2012 11:09, schrieb Mark Thomas: On 31/05/2012 10:02, Christian Finckler wrote: Hello, as far I understood, the websocket implementation of tomcat is using one thread per client. Is there also a possibility to configure it to use non blocking IO? No. That has not yet been implemented. It shouldn't be too hard provided that non-blocking is used between messages and blocking is used during messages. Obviously, the BIO connector will always use blocking. Whoops. My bad. I implemented this already. NIO and APR/native will be non-blocking between messages and have been since the first Tomcat release to include WebSocket support. Note that all connectors will block between the point the upgrade is started and the first message is sent. This was on my to-do list for a while and I simply forgot I had actually implemented. Had I looked at the code first (like I just did) it would have been clear that this was implemented. Sorry for the mis-information. Mark Hello Mark, you have confused me a bit. So there isn't one thread for each websocket client used? For the BIO connector it is always one thread == one connection. You cannot do non-blocking IO with the blocking IO connector. For NIO and APR/native is: - as many connections as you like up to maxConnections - one thread == WebSocket frame The threads are taken from the connector's connection pool and are returned once the WebSocket frame has been read. Reads are non-blocking between frames but blocking during a frame (to save having track detailed state between reads) Writes are always blocking. In short, if the client isn't sending any data, Tomcat doesn't allocate a thread to read it. The poller monitors the connection and passes it to a thread when there is a message to read. If not. What are the configuration possibilities for that? maxThreads, maxConnections on the connector just like HTTP. And how to do it? Use the NIO or APR/native connector and it just works. Perhaps you can describe more deeply how you handle websockets in regard of blocking/non blocking and thread handling? See above. If you want more detail, look at the source code. I am not going to translate that into pseudo code for you. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
non blocking Websockets?
Hello, as far I understood, the websocket implementation of tomcat is using one thread per client. Is there also a possibility to configure it to use non blocking IO? Then it should be easier to serve lots of connections without creating unlimited threads. Thank you, Chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: non blocking Websockets?
On 31/05/2012 10:02, Christian Finckler wrote: Hello, as far I understood, the websocket implementation of tomcat is using one thread per client. Is there also a possibility to configure it to use non blocking IO? No. That has not yet been implemented. It shouldn't be too hard provided that non-blocking is used between messages and blocking is used during messages. Obviously, the BIO connector will always use blocking. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: non blocking Websockets?
Am 31.05.2012 11:09, schrieb Mark Thomas: On 31/05/2012 10:02, Christian Finckler wrote: Hello, as far I understood, the websocket implementation of tomcat is using one thread per client. Is there also a possibility to configure it to use non blocking IO? No. That has not yet been implemented. It shouldn't be too hard provided that non-blocking is used between messages and blocking is used during messages. Obviously, the BIO connector will always use blocking. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org Ok, if that is so easy, it should be done. I am developing an online game, in which the player dont send messages very often (max: ten messages per minute), but is is very important to get the messages of other players very fast. Thats why I want to use websockets. But now it would be sad, if I need multiple tomcat instances only for connection handling although the process handling itself is not very complicated (cpu and memory intensive). Thank you, Chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: non blocking Websockets?
You can achieve that right now. Use the NIO connector, And then set up the write buffer: Connector protocol=org.apache.coyote.http11.Http11NioProtocol socket.txBufSize=set socket buffer size in bytes here The only blocking aspect the connector actually has is to put the data in the OS TCP write buffer. After that, the OS delivers it asynchronously. So if you size this buffer correctly, you will achieve complete non blocking data Filip -Original Message- From: Christian Finckler [mailto:christian.finck...@gmx.de] Sent: Thursday, May 31, 2012 11:45 AM To: Tomcat Users List Subject: Re: non blocking Websockets? Am 31.05.2012 11:09, schrieb Mark Thomas: On 31/05/2012 10:02, Christian Finckler wrote: Hello, as far I understood, the websocket implementation of tomcat is using one thread per client. Is there also a possibility to configure it to use non blocking IO? No. That has not yet been implemented. It shouldn't be too hard provided that non-blocking is used between messages and blocking is used during messages. Obviously, the BIO connector will always use blocking. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org Ok, if that is so easy, it should be done. I am developing an online game, in which the player dont send messages very often (max: ten messages per minute), but is is very important to get the messages of other players very fast. Thats why I want to use websockets. But now it would be sad, if I need multiple tomcat instances only for connection handling although the process handling itself is not very complicated (cpu and memory intensive). Thank you, Chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org