You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kjell Winblad <kj...@digitalroute.com> on 2008/05/22 15:31:39 UTC

Endpoint#stop() does not close opened port and what happen to received requests when it is called?

Hi,

I have two question regarding the closing of services. I have made an
user interface for a webservice and it shall be possible to start and
stop the service from the interface. I use the following code to create
and publish the service:

import javax.xml.ws.Endpoint;
import org.apache.cxf.jaxws.EndpointImpl;

...

GreeterImpl serverImpl = new GreeterImpl()
Endpoint end = Endpoint.create(serverImpl);
EndpointImpl endpoint = (EndpointImpl) end;
endpoint.setWsdlLocation(wsdlfile);
end.publish("http://localhost:6002/WS");

The server uses HTTP as transport and works great. When I check the
opened ports on my machine I can see that CXF has opened the port I
specified in my publish address. The problem occures when I try to stop
the service. I use the the method stop() on my endpont instance. No
exceptions are thrown and it isn't possible to send requests to the
service anymore. So, the stop method seems to work but the opened port
is still open. What is supposed to happen when stop() is called on an
Endpoint, shall the associated port close? If it shall stay open how do
I close a port that has been opened by the Endpoint#publish() method?

The second question is:
What happens with received but not processed requests when
Endpoint#stop() is called? Before the service is stopped I want to be
sure that response messages for all the requests that already have been
recived to the service have been sent. So, does the Endpoint#stop()
method wait until all response messages for incoming request have been
sent before it stops the service?

Thanks in advance,
Kjell Winblad 



Re: Endpoint#stop() does not close opened port and what happen to received requests when it is called?

Posted by Benson Margulies <bi...@gmail.com>.
This is, of course, related to the classic issue of TCP port reuse and
security. By default, Jetty does not set SO_REUSEADDR, as is
appropriate in a secure environment. We added some wiring to plug into
some Jetty wiring to turn it on. However, if you use this, you are
subject to the security issue that started this in the first place
years ago.

It's not convenient, but it's much better to keep the port open and
just change around what endpoints are registered in Jetty rather than
trying to flip the port up and down.


On Thu, May 22, 2008 at 10:55 PM, Daniel Kulp <dk...@apache.org> wrote:
>
> We've had major problems with Jetty with shutting down the port and then
> retrying to restart it immediately.
> If we tried to cycle things quickly (like a shutdown of one service and than
> immediately a publish of another on the same port), then requests to the
> second service sometimes wouldn't get there.   Caveat: I'm not sure if the
> latest Jetty versions have fixed that.
>
> In general, we leave it open as that was the only way to make sure we can
> reliably get the messages.    To completely shut it down, you need to
> shutdown the bus.  BusFactory.getDefaultBus().shutdown(true); should
> completely shutdown everything.
>
> To answer your other questions, when you stop a service, all that happens is
> that the Handler is unregistered with Jetty.  Thus, requests that have
> already been dispatched to the handler will continue.   Future requests
> would get a 404.
>
> Dan
>
>
>
> On May 22, 2008, at 9:31 AM, Kjell Winblad wrote:
>
>> Hi,
>>
>> I have two question regarding the closing of services. I have made an
>> user interface for a webservice and it shall be possible to start and
>> stop the service from the interface. I use the following code to create
>> and publish the service:
>>
>> import javax.xml.ws.Endpoint;
>> import org.apache.cxf.jaxws.EndpointImpl;
>>
>> ...
>>
>> GreeterImpl serverImpl = new GreeterImpl()
>> Endpoint end = Endpoint.create(serverImpl);
>> EndpointImpl endpoint = (EndpointImpl) end;
>> endpoint.setWsdlLocation(wsdlfile);
>> end.publish("http://localhost:6002/WS");
>>
>> The server uses HTTP as transport and works great. When I check the
>> opened ports on my machine I can see that CXF has opened the port I
>> specified in my publish address. The problem occures when I try to stop
>> the service. I use the the method stop() on my endpont instance. No
>> exceptions are thrown and it isn't possible to send requests to the
>> service anymore. So, the stop method seems to work but the opened port
>> is still open. What is supposed to happen when stop() is called on an
>> Endpoint, shall the associated port close? If it shall stay open how do
>> I close a port that has been opened by the Endpoint#publish() method?
>>
>> The second question is:
>> What happens with received but not processed requests when
>> Endpoint#stop() is called? Before the service is stopped I want to be
>> sure that response messages for all the requests that already have been
>> recived to the service have been sent. So, does the Endpoint#stop()
>> method wait until all response messages for incoming request have been
>> sent before it stops the service?
>>
>> Thanks in advance,
>> Kjell Winblad
>>
>>
>
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
>
>
>

Re: Endpoint#stop() does not close opened port and what happen to received requests when it is called?

Posted by Daniel Kulp <dk...@apache.org>.
We've had major problems with Jetty with shutting down the port and  
then retrying to restart it immediately.
If we tried to cycle things quickly (like a shutdown of one service  
and than immediately a publish of another on the same port), then  
requests to the second service sometimes wouldn't get there.   Caveat:  
I'm not sure if the latest Jetty versions have fixed that.

In general, we leave it open as that was the only way to make sure we  
can reliably get the messages.    To completely shut it down, you need  
to shutdown the bus.  BusFactory.getDefaultBus().shutdown(true);  
should completely shutdown everything.

To answer your other questions, when you stop a service, all that  
happens is that the Handler is unregistered with Jetty.  Thus,  
requests that have already been dispatched to the handler will  
continue.   Future requests would get a 404.

Dan



On May 22, 2008, at 9:31 AM, Kjell Winblad wrote:

> Hi,
>
> I have two question regarding the closing of services. I have made an
> user interface for a webservice and it shall be possible to start and
> stop the service from the interface. I use the following code to  
> create
> and publish the service:
>
> import javax.xml.ws.Endpoint;
> import org.apache.cxf.jaxws.EndpointImpl;
>
> ...
>
> GreeterImpl serverImpl = new GreeterImpl()
> Endpoint end = Endpoint.create(serverImpl);
> EndpointImpl endpoint = (EndpointImpl) end;
> endpoint.setWsdlLocation(wsdlfile);
> end.publish("http://localhost:6002/WS");
>
> The server uses HTTP as transport and works great. When I check the
> opened ports on my machine I can see that CXF has opened the port I
> specified in my publish address. The problem occures when I try to  
> stop
> the service. I use the the method stop() on my endpont instance. No
> exceptions are thrown and it isn't possible to send requests to the
> service anymore. So, the stop method seems to work but the opened port
> is still open. What is supposed to happen when stop() is called on an
> Endpoint, shall the associated port close? If it shall stay open how  
> do
> I close a port that has been opened by the Endpoint#publish() method?
>
> The second question is:
> What happens with received but not processed requests when
> Endpoint#stop() is called? Before the service is stopped I want to be
> sure that response messages for all the requests that already have  
> been
> recived to the service have been sent. So, does the Endpoint#stop()
> method wait until all response messages for incoming request have been
> sent before it stops the service?
>
> Thanks in advance,
> Kjell Winblad
>
>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog