Project

General

Profile

Support #2897

Inter-process communication using POST requests

Added by Alan Finley about 8 years ago. Updated about 8 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
Target version:
-
Start date:
04/03/2014
Due date:
% Done:

0%

Estimated time:

Description

I deploy my Wt application as a FastCGI app under Apache. So, I suppose that every single Wt session is a separate process.

I've figured out that I can send a POST request to a session I want, if I add a static resource to my WServer and specify a session id in the request url like this: POST http://localhost/handler?wtd=<session_id>.

Now I want to repeat this using my own id param, not the hardcoded 'wtd'. I want my WApplication instance to register its new id somewhere, and the I would like to globally keep a list of references between my custom app ids and session ids. Then I want to handle a POST request with my custom id, get matched session id and then forward the request with the 'wtd' parameter specified.

Is it possible to get a list of all sessions created in different processes? Can it be implemented using existing Wt API?

Does Wt have any means of inter-process communication between its own apps?

Is my approach initically wrong? :)

#1

Updated by Koen Deforche about 8 years ago

  • Status changed from New to Feedback
  • Assignee set to Koen Deforche

Hey Alan,

What you want is to customize the forwarding logic in the 'FastCGI dispatching process' which is a process that receives FastCGI requests from the web server and forwards them to the correct session process. This forwarding logic however cannot be customized.

Wt does not come with an inter-process (inter-session) communication system, but that would be a nice feature to have.

Although I follow your technical explanation, what's the use case for this ?

Regards,

koen

#2

Updated by Alan Finley about 8 years ago

I'll try to describe my use case for this.

My app is used as an iframe inside some other web application. My app should be created with some external id and it should accept POST requests and then display the incomging data.

At the moment I implement it this way:

  1. My app gets its external id from WEnvironment params:

Also I set up two static resource handlers: a public one and an internal one.

  1. My app saves its wt session id to a file: /var/tmp/wt_session_12345.txt
  2. Then a calling app sends a POST request to my app public interface:

    curl --data "ext_id=12365&data1=value1&data2=value2" http://localhost:10204/api

  3. My static resource handler catches the request, gets external app id, opens file and reads the wt session id value. Then it adds the "wtd=" param and resends the request to the second (internal) resource handler.

  4. The internal handler gets the data and posts it to the application using WServer::post.

#3

Updated by Koen Deforche about 8 years ago

Hey Alan,

Thanks for the use-case. It makes sense and indeed Wt does not particularly help to implement this. I guess an inter-session communication class which allows you to send a message to a session (regardless of whether the target session is inside or outside your current process) would be somewhat helpful?

Regards,

koen

#4

Updated by Alan Finley about 8 years ago

Koen Deforche wrote:

I guess an inter-session communication class which allows you to send a message to a session (regardless of whether the target session is inside or outside your current process) would be somewhat helpful?

Yes, that would be great.

Also, it would be nice to have some words in the documentation about the 'wtd' param, which is necessary if you want to post a request to a specific session running in a separate process.

Also available in: Atom PDF