You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jason Ricles <jg...@alum.lehigh.edu> on 2014/10/25 21:41:15 UTC

tomcat websocket communication with external java program

I have a tomcat webpage with a websocket server written in java to
communicate with the webpage. I want this websocket server to be able to
communicate with an external java program without an sockets, so something
like this

webpage<---------------->websocket server<---------------->external java
program


However I am having trouble getting that to work, since to use the
websocket server I need to make an instance of it and thus it thinks there
are no session. So currently I have done it the following way

webpage<------------->websocket
server<---------------------->socket<------------------->external java
program

This is kinda messy however, so is there some way to get my external java
program and my webpage to communicate through websockets without a socket
go between?

Re: tomcat websocket communication with external java program

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jason,

On 10/25/14 3:41 PM, Jason Ricles wrote:
> I have a tomcat webpage with a websocket server written in java to 
> communicate with the webpage. I want this websocket server to be
> able to communicate with an external java program without an
> sockets, so something like this
> 
> webpage<---------------->websocket server<---------------->external
> java program
> 
> 
> However I am having trouble getting that to work, since to use the 
> websocket server I need to make an instance of it and thus it
> thinks there are no session.

What do you mean "websocket session"?

Are you trying to use the HttpSession from a websocket call? Or only
for the HTTP call that precedes the websocket upgrade?

If you just want to inherit the session, then make sure you send a
JSESSIONID cookie or ";jsessionid" path parameter in your URL with
your initial connection.

Are you launching your own Websocket server, or are you allowing
Tomcat to host the Websocket server like in a "normal" configuration?

> So currently I have done it the following way
> 
> webpage<------------->websocket 
> server<---------------------->socket<------------------->external
> java program
> 
> This is kinda messy however, so is there some way to get my
> external java program and my webpage to communicate through
> websockets without a socket go between?

I don't think this extra step is necessary, but it's pretty tough to
understand what you are trying to do.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUTPOPAAoJEBzwKT+lPKRYAhAQAJghL4HjgjuEWBIbO0NQSRa7
D5i+raJCmN2dQSC0sfnsEW5NrMpKr6I0KWVBp3kjBYjXzXZ1VDbU1vPYP+O391xK
kCSqEWmwz642uCHC060DES2u9AaWkJ9RoLMRKv2LcQ0VwEFeudxe1GP8Mjjk7kYq
WtfsF0e1XU4ncYr6p1qUR0jK3Ipk4UrfnxTkU5//eqy10478uLvCIE+mdOSEjfS5
bzBy3ZMIQ0teTVkNNT4WxfUX5gxieYBsXWPLcoup01Rn1FCXwrf2x+YEZwRVJxl3
j40vWMj3O+oHCfhJcJTFhUlpeCU8kTZZdNV29qP4NKLgH7v6x+lkNor7THhNznLE
ei0t4j5pX0KeLRRA+3K+tPMRLTE514aFwmrsCmw1zyE8SKrUxl8flxwcftJUMgBO
6gyGbm8drkdqmTSusDMBquuDi+TaGkaBGftAWMPH2ev5Cvklu+YS0JwWJ8N9/8NF
lZ2hT2YabXmac+7n0PyDWT3d1CquuE/mxrtGAMZ8OP5ji6U00uStrUZiWLiFuKkX
ikX0tGgsvYvVs9Hjpwjiy+zPGx231qnsfnJzrjiA0L3TxT/l7nnUMqWDlt9E3JgM
dJy34nk49z6ic3JyC1vdOztJc/M1SzrkZBSwqk+A922JBSI8CZz0p3sYS03ePcjv
3fb4POPO8ilqsHskSLcX
=oalw
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat websocket communication with external java program

Posted by Igor Kolomiets <sa...@gmail.com>.
All you need to do is to have your "external java" use a websocket
client (like Jetty's
http://www.eclipse.org/jetty/documentation/current/jetty-websocket-client-api.html)
to connect to your server's websocket endpoint.
--
Igor Kolomiets


On Sat, Oct 25, 2014 at 3:41 PM, Jason Ricles <jg...@alum.lehigh.edu> wrote:
> I have a tomcat webpage with a websocket server written in java to
> communicate with the webpage. I want this websocket server to be able to
> communicate with an external java program without an sockets, so something
> like this
>
> webpage<---------------->websocket server<---------------->external java
> program
>
>
> However I am having trouble getting that to work, since to use the
> websocket server I need to make an instance of it and thus it thinks there
> are no session. So currently I have done it the following way
>
> webpage<------------->websocket
> server<---------------------->socket<------------------->external java
> program
>
> This is kinda messy however, so is there some way to get my external java
> program and my webpage to communicate through websockets without a socket
> go between?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org