The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » Metro and JAXB

Thread: What is the proper way to push data to a client

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 9 - Last Post: Aug 31, 2008 6:20 PM by: Clive Brettingh...
uprooter

Posts: 25
What is the proper way to push data to a client
Posted: Aug 29, 2008 2:01 AM
 
  Click to reply to this thread Reply

Hello.
I'm building an multi-tired application that should allow remote control over PC's.
I want each PC to connect to my server as a web services client and wait for instructions from the server.
The client must be the HTTP connection initiator. and inform the server about occurrence of some unpredictable events.
The question is how should I make the client wait for instructions from server?
Is there a way to do 2 way web methods invokes in a way that the server can invoke methods on the client just like that the client can invoke methods on the server?

Felipe Gaúcho
Re: What is the proper way to push data to a client
Posted: Aug 29, 2008 2:01 AM   in response to: uprooter
  Click to reply to this thread Reply

use AJAX.. it is perfect for that purposes.. you also have reverse
AJAX, what gives the server full control over the client's behavior if
you want :)

On Fri, Aug 29, 2008 at 11:01 AM, <metro@javadesktop.org> wrote:
> Hello.
> I'm building an multi-tired application that should allow remote control over PC's.
> I want each PC to connect to my server as a web services client and wait for instructions from the server.
> The client must be the HTTP connection initiator. and inform the server about occurrence of some unpredictable events.
> The question is how should I make the client wait for instructions from server?
> Is there a way to do 2 way web methods invokes in a way that the server can invoke methods on the client just like that the client can invoke methods on the server?
> [Message sent by forum member 'uprooter' (uprooter)]
>
> http://forums.java.net/jive/thread.jspa?messageID=296101
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net


Felipe Gaúcho
Re: What is the proper way to push data to a client
Posted: Aug 29, 2008 2:01 AM   in response to: Felipe Gaúcho
  Click to reply to this thread Reply

I mean, if you are using classicial service oriented approach, your
client and your services should be decoupled.. but if you need a fine
grain control on special situations, you should include a layer
between service calls and the response to the client.. traditionally a
servlet..

On Fri, Aug 29, 2008 at 10:51 AM, Felipe Gaúcho <fgaucho@gmail.com> wrote:
> use AJAX.. it is perfect for that purposes.. you also have reverse
> AJAX, what gives the server full control over the client's behavior if
> you want :)
>
> On Fri, Aug 29, 2008 at 11:01 AM, <metro@javadesktop.org> wrote:
>> Hello.
>> I'm building an multi-tired application that should allow remote control over PC's.
>> I want each PC to connect to my server as a web services client and wait for instructions from the server.
>> The client must be the HTTP connection initiator. and inform the server about occurrence of some unpredictable events.
>> The question is how should I make the client wait for instructions from server?
>> Is there a way to do 2 way web methods invokes in a way that the server can invoke methods on the client just like that the client can invoke methods on the server?
>> [Message sent by forum member 'uprooter' (uprooter)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=296101
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
>> For additional commands, e-mail: users-help@metro.dev.java.net
>>
>>
>


uprooter

Posts: 25
Re: What is the proper way to push data to a client
Posted: Aug 29, 2008 2:39 AM   in response to: Felipe Gaúcho
 
  Click to reply to this thread Reply

Well I thought AJAX is for web sites and browsers.
I need no user interaction at all.
My clients will be silent .NET windows services that communicates with the server. (decoupled enough ?)
how does another layer can make the server call methods on the client (and let's assume that my clients are behind NAT and has no open ports)

Felipe Gaúcho
Re: What is the proper way to push data to a client
Posted: Aug 29, 2008 2:39 AM   in response to: uprooter
  Click to reply to this thread Reply

well, in this scenario, "The question is how should I make the client
wait for instructions from server?"

your client will ba w WCF service, right ? (or ASP service, doesn't
matter the technology), so you should have:

- at least one input port opened on the client side...
- the client should can transfer a unique identification to the server
(in secure communication you can use the credential of the client)
- the server has a map between client ID and its endpoints (IP, etc..)

Other: your server can add the response message to a queue,and the
consumer of th queue becomes responsible to dispatch the response
message to the original client.. (in this case, you remove from the
server the addresses mapping and other external details). The message
option also gives you more reliability, delegating to the Glassfih
queue infra-structure the fail over processes, etc....

just toughts, I hope that helps........

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net


uprooter

Posts: 25
Re: What is the proper way to push data to a client
Posted: Aug 29, 2008 3:32 AM   in response to: Felipe Gaúcho
 
  Click to reply to this thread Reply

Thanks Felipe.
My client will be a WCF service.
But I still dont get it.
Open input port on the client side is not an option.
Moreover, the client may be behind HTTP proxy.

Felipe Gaúcho
Re: What is the proper way to push data to a client
Posted: Aug 29, 2008 3:53 AM   in response to: uprooter
  Click to reply to this thread Reply

> Open input port on the client side is not an option.
> Moreover, the client may be behind HTTP proxy.

So, perhaps the best way is to "request the response" from time to time :(

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net


Clive Brettingh...
Re: What is the proper way to push data to a client
Posted: Aug 29, 2008 5:57 AM   in response to: uprooter
  Click to reply to this thread Reply

Depending on the responsiveness you require there are several methods.
If real time responsiveness is not needed and you don't mind a fair bit
of network traffic clients can just periodically poll the server.
If you want a little more responsiveness there is an old web application
trick where the server delays sending the response (will need to tune
the time according to the proxy timeout behavior), giving a window
where the response can be sent to the waiting client as soon as it
becomes available.
Alternatively, if you can ditch HTTP (and wed services) altogether you
can just use an old fashioned long lived TCP connection - should work
fine though NAT/PAT though trickier through a HTTP proxy.

I've actually used all three of the above in different aspects of the
one application.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net


uprooter

Posts: 25
Re: What is the proper way to push data to a client
Posted: Aug 31, 2008 4:43 AM   in response to: Clive Brettingh...
 
  Click to reply to this thread Reply

Thanks Clive.
About the "old web application trick":
Isn't it what's being done in a simple async call ?
I mean
When a client invokes a WS asynchronously, there is, sometimes a long period of inactivity before the server sends the reply.
I assume that in this delayed response the HTTP connection is kept alive and then reused when the reply arrives from the server.
If that's true, this sound like what Im looking for.
I just need to make sure that the time between the method call and the response is long enough for my needs, (infinite hopefully) .

Clive Brettingh...
Re: What is the proper way to push data to a client
Posted: Aug 31, 2008 6:20 PM   in response to: uprooter
  Click to reply to this thread Reply

Yes, it is basically an async call, the difference being that the server
deliberately delays responding until there is a significant state change
due to activity in a separate thread; normally one aims to have simple
single thread operation responding ASAP.

The main disadvantage is that since your server is likely to be using a
tread per request processing model you are tying up a server thread for
this time, so since you have a limited number of server threads if there
are many clients you will see responsiveness problems (or even rejected
connections). Servers that don't use thread-per-request blocking
processing avoid this, but they are not common.

Also, unless your server and client are directly connected (and
configured correctly for infinite timeouts) you will probably not be
able to get an infinite timeout (http proxies will generally have their
own timeouts (often only 5 min or so), as will NAT gateways (typically 2
hours))

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net





 XML java.net RSS