You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kevin Priebe <ke...@realtyserver.com> on 2009/06/17 23:53:30 UTC
Connection timeout ignored
Hi, I am doing some testing with connection time outs with CXF 2.2.2. I am
setting it programmatially using the HTTPClientPolicy (see code below). It
seems the timeout is ignored if the web server is offline. I can set the
timeout to any value and it will consistently timeout after about 2 seconds
(which is very low!). The timeout does seem to work correctly when I simply
put Thread.sleep() in the ping() service method, or maybe that's just the
receive timeout working by that point... I am not using spring at all on
the client, no spring jars or anything. Here is my client code:
--------------------------------
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(serviceInterface);
factory.setAddress(url);
AegisDatabinding binding = new AegisDatabinding();
binding.setMtomEnabled(mtom);
factory.setDataBinding(binding);
MyService service = (MyService)factory.create();
Client cl = ClientProxy.getClient(service);
HTTPConduit http = (HTTPConduit) cl.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(10000);
httpClientPolicy.setReceiveTimeout(10000);
httpClientPolicy.setAllowChunking(true);
httpClientPolicy.setMaxRetransmits(3);
http.setClient(httpClientPolicy);
service.ping();
---------------------------
It also seems like the max retransmits is ignored too.. but I can't confirm
that yet. The connection timeout is a problem because it causes errors for
our users when they have a flaky network connection, or if we have to reload
the web service for some reason (usually goes offline for 5 seconds). This
never used to be a problem for us when we used XFire, because it would retry
3 times and had a decent timeout that was not ignored. Is there something
else I can do to fix this? It's causing quite a few problems with users
since the switch to CXF... Thanks,
Kevin
Re: Connection timeout ignored
Posted by Daniel Kulp <dk...@apache.org>.
Is the Exception you are getting a "Connection Refused" or "Connection Timed
Out"? If the server isn't running, it's probably the first and the timeout
will have nothing to do with that.
You can test it with a straight HttpURLConnection. Set the timeouts, and see
what exception is raised and such.
Dan
On Thu June 18 2009 5:50:46 pm Kevin Priebe wrote:
> I have now tried this with Java 6u13, 6u14, and an older 6u5 with the same
> results. The connection timeout and max retransmits are ignored even after
> setting auto redirect = true.
>
> Is no one else having problems with this? Can anyone reproduce my results?
> Should be pretty easy, just turn off the web server (not your production
> one
>
> :P) and try to make a web service call and print out how long it takes to
>
> time out. I would at least feel better if I'm not the only one that this
> affects...
>
> Kevin
>
>
> -----Original Message-----
> From: Kevin Priebe [mailto:kevin@realtyserver.com]
> Sent: June-18-09 1:28 PM
> To: users@cxf.apache.org
> Subject: RE: Connection timeout ignored
>
> Thanks for the reply Dan. I was using Java 6u13. Today I tried it out
> with the latest 6u14 and it still times out between 2 and 3 seconds no
> matter what I do.
>
> I set httpClientPolicy.setAutoRedirect(true); and
> httpClientPolicy.setMaxRetransmits(5); and watched the connection attempts
> using tcpmon. It seems to only try 2 times no matter what I set the values
> to...
>
> Somewhere deep in the Internet, I found someone suggesting to do
> System.setProperty( "sun.net.client.defaultConnectTimeout", "5000" );, but
> that also did nothing for me.
>
> Maybe I'll try with an older version of Java and see what happens... Any
> other suggestions would be great as I am quite stuck.
>
> Kevin
>
>
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: June-18-09 12:02 PM
> To: users@cxf.apache.org
> Cc: Kevin Priebe
> Subject: Re: Connection timeout ignored
>
>
> We just set the connectionTimeout setting on the HTTPUrlConnection object.
>
> Thus, if that's not working, that would probably be a JDK bug. :-(
>
> On the re-transmits.... Looks like there is a bug. If you add:
>
> httpClientPolicy.setAutoRedirect(true);
>
> then I think it will work. Basically, for the retransmits, we need to
> buffer
> the message. Turning on the AutoRedirect turns on the buffering. We
> should
> also turn it on if the retransmits are > 0.
>
> Dan
>
> On Wed June 17 2009 5:53:30 pm Kevin Priebe wrote:
> > Hi, I am doing some testing with connection time outs with CXF 2.2.2. I
>
> am
>
> > setting it programmatially using the HTTPClientPolicy (see code below).
>
> It
>
> > seems the timeout is ignored if the web server is offline. I can set the
> > timeout to any value and it will consistently timeout after about 2
>
> seconds
>
> > (which is very low!). The timeout does seem to work correctly when I
> > simply put Thread.sleep() in the ping() service method, or maybe that's
> > just the receive timeout working by that point... I am not using spring
>
> at
>
> > all on the client, no spring jars or anything. Here is my client code:
> >
> >
> >
> > --------------------------------
> >
> > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> >
> > factory.setServiceClass(serviceInterface);
> >
> > factory.setAddress(url);
> >
> >
> >
> > AegisDatabinding binding = new AegisDatabinding();
> >
> > binding.setMtomEnabled(mtom);
> >
> > factory.setDataBinding(binding);
> >
> >
> >
> > MyService service = (MyService)factory.create();
> >
> >
> >
> > Client cl = ClientProxy.getClient(service);
> >
> >
> >
> > HTTPConduit http = (HTTPConduit) cl.getConduit();
> >
> >
> >
> > HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
> >
> > httpClientPolicy.setConnectionTimeout(10000);
> >
> > httpClientPolicy.setReceiveTimeout(10000);
> >
> > httpClientPolicy.setAllowChunking(true);
> >
> > httpClientPolicy.setMaxRetransmits(3);
> >
> >
> >
> > http.setClient(httpClientPolicy);
> >
> >
> >
> > service.ping();
> >
> > ---------------------------
> >
> >
> >
> > It also seems like the max retransmits is ignored too.. but I can't
>
> confirm
>
> > that yet. The connection timeout is a problem because it causes errors
>
> for
>
> > our users when they have a flaky network connection, or if we have to
> > reload the web service for some reason (usually goes offline for 5
> > seconds). This never used to be a problem for us when we used XFire,
> > because it would retry 3 times and had a decent timeout that was not
> > ignored. Is there something else I can do to fix this? It's causing
>
> quite
>
> > a few problems with users since the switch to CXF... Thanks,
> >
> >
> >
> > Kevin
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
RE: Connection timeout ignored
Posted by Kevin Priebe <ke...@realtyserver.com>.
I have now tried this with Java 6u13, 6u14, and an older 6u5 with the same
results. The connection timeout and max retransmits are ignored even after
setting auto redirect = true.
Is no one else having problems with this? Can anyone reproduce my results?
Should be pretty easy, just turn off the web server (not your production one
:P) and try to make a web service call and print out how long it takes to
time out. I would at least feel better if I'm not the only one that this
affects...
Kevin
-----Original Message-----
From: Kevin Priebe [mailto:kevin@realtyserver.com]
Sent: June-18-09 1:28 PM
To: users@cxf.apache.org
Subject: RE: Connection timeout ignored
Thanks for the reply Dan. I was using Java 6u13. Today I tried it out with
the latest 6u14 and it still times out between 2 and 3 seconds no matter
what I do.
I set httpClientPolicy.setAutoRedirect(true); and
httpClientPolicy.setMaxRetransmits(5); and watched the connection attempts
using tcpmon. It seems to only try 2 times no matter what I set the values
to...
Somewhere deep in the Internet, I found someone suggesting to do
System.setProperty( "sun.net.client.defaultConnectTimeout", "5000" );, but
that also did nothing for me.
Maybe I'll try with an older version of Java and see what happens... Any
other suggestions would be great as I am quite stuck.
Kevin
-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org]
Sent: June-18-09 12:02 PM
To: users@cxf.apache.org
Cc: Kevin Priebe
Subject: Re: Connection timeout ignored
We just set the connectionTimeout setting on the HTTPUrlConnection object.
Thus, if that's not working, that would probably be a JDK bug. :-(
On the re-transmits.... Looks like there is a bug. If you add:
httpClientPolicy.setAutoRedirect(true);
then I think it will work. Basically, for the retransmits, we need to
buffer
the message. Turning on the AutoRedirect turns on the buffering. We
should
also turn it on if the retransmits are > 0.
Dan
On Wed June 17 2009 5:53:30 pm Kevin Priebe wrote:
> Hi, I am doing some testing with connection time outs with CXF 2.2.2. I
am
> setting it programmatially using the HTTPClientPolicy (see code below).
It
> seems the timeout is ignored if the web server is offline. I can set the
> timeout to any value and it will consistently timeout after about 2
seconds
> (which is very low!). The timeout does seem to work correctly when I
> simply put Thread.sleep() in the ping() service method, or maybe that's
> just the receive timeout working by that point... I am not using spring
at
> all on the client, no spring jars or anything. Here is my client code:
>
>
>
> --------------------------------
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>
> factory.setServiceClass(serviceInterface);
>
> factory.setAddress(url);
>
>
>
> AegisDatabinding binding = new AegisDatabinding();
>
> binding.setMtomEnabled(mtom);
>
> factory.setDataBinding(binding);
>
>
>
> MyService service = (MyService)factory.create();
>
>
>
> Client cl = ClientProxy.getClient(service);
>
>
>
> HTTPConduit http = (HTTPConduit) cl.getConduit();
>
>
>
> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
>
> httpClientPolicy.setConnectionTimeout(10000);
>
> httpClientPolicy.setReceiveTimeout(10000);
>
> httpClientPolicy.setAllowChunking(true);
>
> httpClientPolicy.setMaxRetransmits(3);
>
>
>
> http.setClient(httpClientPolicy);
>
>
>
> service.ping();
>
> ---------------------------
>
>
>
> It also seems like the max retransmits is ignored too.. but I can't
confirm
> that yet. The connection timeout is a problem because it causes errors
for
> our users when they have a flaky network connection, or if we have to
> reload the web service for some reason (usually goes offline for 5
> seconds). This never used to be a problem for us when we used XFire,
> because it would retry 3 times and had a decent timeout that was not
> ignored. Is there something else I can do to fix this? It's causing
quite
> a few problems with users since the switch to CXF... Thanks,
>
>
>
> Kevin
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
RE: Connection timeout ignored
Posted by Kevin Priebe <ke...@realtyserver.com>.
Thanks for the reply Dan. I was using Java 6u13. Today I tried it out with
the latest 6u14 and it still times out between 2 and 3 seconds no matter
what I do.
I set httpClientPolicy.setAutoRedirect(true); and
httpClientPolicy.setMaxRetransmits(5); and watched the connection attempts
using tcpmon. It seems to only try 2 times no matter what I set the values
to...
Somewhere deep in the Internet, I found someone suggesting to do
System.setProperty( "sun.net.client.defaultConnectTimeout", "5000" );, but
that also did nothing for me.
Maybe I'll try with an older version of Java and see what happens... Any
other suggestions would be great as I am quite stuck.
Kevin
-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org]
Sent: June-18-09 12:02 PM
To: users@cxf.apache.org
Cc: Kevin Priebe
Subject: Re: Connection timeout ignored
We just set the connectionTimeout setting on the HTTPUrlConnection object.
Thus, if that's not working, that would probably be a JDK bug. :-(
On the re-transmits.... Looks like there is a bug. If you add:
httpClientPolicy.setAutoRedirect(true);
then I think it will work. Basically, for the retransmits, we need to
buffer
the message. Turning on the AutoRedirect turns on the buffering. We
should
also turn it on if the retransmits are > 0.
Dan
On Wed June 17 2009 5:53:30 pm Kevin Priebe wrote:
> Hi, I am doing some testing with connection time outs with CXF 2.2.2. I
am
> setting it programmatially using the HTTPClientPolicy (see code below).
It
> seems the timeout is ignored if the web server is offline. I can set the
> timeout to any value and it will consistently timeout after about 2
seconds
> (which is very low!). The timeout does seem to work correctly when I
> simply put Thread.sleep() in the ping() service method, or maybe that's
> just the receive timeout working by that point... I am not using spring
at
> all on the client, no spring jars or anything. Here is my client code:
>
>
>
> --------------------------------
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>
> factory.setServiceClass(serviceInterface);
>
> factory.setAddress(url);
>
>
>
> AegisDatabinding binding = new AegisDatabinding();
>
> binding.setMtomEnabled(mtom);
>
> factory.setDataBinding(binding);
>
>
>
> MyService service = (MyService)factory.create();
>
>
>
> Client cl = ClientProxy.getClient(service);
>
>
>
> HTTPConduit http = (HTTPConduit) cl.getConduit();
>
>
>
> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
>
> httpClientPolicy.setConnectionTimeout(10000);
>
> httpClientPolicy.setReceiveTimeout(10000);
>
> httpClientPolicy.setAllowChunking(true);
>
> httpClientPolicy.setMaxRetransmits(3);
>
>
>
> http.setClient(httpClientPolicy);
>
>
>
> service.ping();
>
> ---------------------------
>
>
>
> It also seems like the max retransmits is ignored too.. but I can't
confirm
> that yet. The connection timeout is a problem because it causes errors
for
> our users when they have a flaky network connection, or if we have to
> reload the web service for some reason (usually goes offline for 5
> seconds). This never used to be a problem for us when we used XFire,
> because it would retry 3 times and had a decent timeout that was not
> ignored. Is there something else I can do to fix this? It's causing
quite
> a few problems with users since the switch to CXF... Thanks,
>
>
>
> Kevin
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
Re: Connection timeout ignored
Posted by Daniel Kulp <dk...@apache.org>.
We just set the connectionTimeout setting on the HTTPUrlConnection object.
Thus, if that's not working, that would probably be a JDK bug. :-(
On the re-transmits.... Looks like there is a bug. If you add:
httpClientPolicy.setAutoRedirect(true);
then I think it will work. Basically, for the retransmits, we need to buffer
the message. Turning on the AutoRedirect turns on the buffering. We should
also turn it on if the retransmits are > 0.
Dan
On Wed June 17 2009 5:53:30 pm Kevin Priebe wrote:
> Hi, I am doing some testing with connection time outs with CXF 2.2.2. I am
> setting it programmatially using the HTTPClientPolicy (see code below). It
> seems the timeout is ignored if the web server is offline. I can set the
> timeout to any value and it will consistently timeout after about 2 seconds
> (which is very low!). The timeout does seem to work correctly when I
> simply put Thread.sleep() in the ping() service method, or maybe that's
> just the receive timeout working by that point... I am not using spring at
> all on the client, no spring jars or anything. Here is my client code:
>
>
>
> --------------------------------
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>
> factory.setServiceClass(serviceInterface);
>
> factory.setAddress(url);
>
>
>
> AegisDatabinding binding = new AegisDatabinding();
>
> binding.setMtomEnabled(mtom);
>
> factory.setDataBinding(binding);
>
>
>
> MyService service = (MyService)factory.create();
>
>
>
> Client cl = ClientProxy.getClient(service);
>
>
>
> HTTPConduit http = (HTTPConduit) cl.getConduit();
>
>
>
> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
>
> httpClientPolicy.setConnectionTimeout(10000);
>
> httpClientPolicy.setReceiveTimeout(10000);
>
> httpClientPolicy.setAllowChunking(true);
>
> httpClientPolicy.setMaxRetransmits(3);
>
>
>
> http.setClient(httpClientPolicy);
>
>
>
> service.ping();
>
> ---------------------------
>
>
>
> It also seems like the max retransmits is ignored too.. but I can't confirm
> that yet. The connection timeout is a problem because it causes errors for
> our users when they have a flaky network connection, or if we have to
> reload the web service for some reason (usually goes offline for 5
> seconds). This never used to be a problem for us when we used XFire,
> because it would retry 3 times and had a decent timeout that was not
> ignored. Is there something else I can do to fix this? It's causing quite
> a few problems with users since the switch to CXF... Thanks,
>
>
>
> Kevin
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog