Zinc Server in Gemstone

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Zinc Server in Gemstone

GLASS mailing list
Hi!

I'm trying to port some working Pharo code to Gemstone.

I have a small project which consists in sending some data from different Pharo images to another one that simply stores it in some object. In order to do that, I create a Zinc Server, make it listen on port 9090 and delegate the requests to my app, like this:

(ZnServer on: 9090) start; delegate: myApp.

In the other Pharo images I just send POST requests like this:

ZnEasy post: 'http://localhost:9090/store' data: (ZnEntity text: someData).

This code is working but I'm running into some trouble trying to port it to Gemstone. So far, I have loaded and tested my app in Gemstone (without changing anything), but the server part is giving me some headaches.

Right now i'm working with the gemstone shell in tODE. I tried executing there this line of code:

eval `(ZnServer on: 9090) start; delegate: myApp`.

After doing this, I can send post requests from the shell itself and it works, but when I try to send a request from a Pharo image I get a "Data received time out". However, when I send a POST request from the shell, all previous requests from the Pharo Images are executed and all sets of data are stored.

So, if I send a POST request from a Pharo image and immediately send a POST request from the Gemstone Shell, it works: both sets of data are stored and both responses are received.

But I would like it to work without having to send dummy post requests from the shell. I don't understand what goes wrong. Maybe I have to do things in a different way? I'm just starting to work with Gemstone and there are a lot of concepts that I don't quite get yet, but I'd really like to learn.

What can I do in order to make it work?

Thanks!

--
David Temnyk

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Zinc Server in Gemstone

GLASS mailing list
I am not sure about the following I will comment ... but... cannot it be that the `eval` uses the same gem as the one running tODE and that may cause some problems? Did you try running the 

(ZnServer on: 9090) start; delegate: myApp

but from a `startTopaz` ?

$GS_HOME/bin/startTopaz myStone -l 

Once inside topaz:

login
run
(ZnServer on: 9090) start; delegate: myApp
%



Cheers,


On Tue, Nov 22, 2016 at 4:27 PM, David Temnyk via Glass <[hidden email]> wrote:
Hi!

I'm trying to port some working Pharo code to Gemstone.

I have a small project which consists in sending some data from different Pharo images to another one that simply stores it in some object. In order to do that, I create a Zinc Server, make it listen on port 9090 and delegate the requests to my app, like this:

(ZnServer on: 9090) start; delegate: myApp.

In the other Pharo images I just send POST requests like this:

ZnEasy post: 'http://localhost:9090/store' data: (ZnEntity text: someData).

This code is working but I'm running into some trouble trying to port it to Gemstone. So far, I have loaded and tested my app in Gemstone (without changing anything), but the server part is giving me some headaches.

Right now i'm working with the gemstone shell in tODE. I tried executing there this line of code:

eval `(ZnServer on: 9090) start; delegate: myApp`.

After doing this, I can send post requests from the shell itself and it works, but when I try to send a request from a Pharo image I get a "Data received time out". However, when I send a POST request from the shell, all previous requests from the Pharo Images are executed and all sets of data are stored.

So, if I send a POST request from a Pharo image and immediately send a POST request from the Gemstone Shell, it works: both sets of data are stored and both responses are received.

But I would like it to work without having to send dummy post requests from the shell. I don't understand what goes wrong. Maybe I have to do things in a different way? I'm just starting to work with Gemstone and there are a lot of concepts that I don't quite get yet, but I'd really like to learn.

What can I do in order to make it work?

Thanks!

--
David Temnyk

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




--

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Zinc Server in Gemstone

GLASS mailing list
Hello Mariano, thank you for your answer.

I tried what you said but sadly I got the same results.

I can't understand why when I make a request from a Pharo Image nothing happens until I send another request from either the tODE shell or topaz...

I must be doing something wrong but I can't figure out what it is.

2016-11-22 17:30 GMT-03:00 Mariano Martinez Peck <[hidden email]>:
I am not sure about the following I will comment ... but... cannot it be that the `eval` uses the same gem as the one running tODE and that may cause some problems? Did you try running the 

(ZnServer on: 9090) start; delegate: myApp

but from a `startTopaz` ?

$GS_HOME/bin/startTopaz myStone -l 

Once inside topaz:

login
run
(ZnServer on: 9090) start; delegate: myApp
%



Cheers,


On Tue, Nov 22, 2016 at 4:27 PM, David Temnyk via Glass <[hidden email]> wrote:
Hi!

I'm trying to port some working Pharo code to Gemstone.

I have a small project which consists in sending some data from different Pharo images to another one that simply stores it in some object. In order to do that, I create a Zinc Server, make it listen on port 9090 and delegate the requests to my app, like this:

(ZnServer on: 9090) start; delegate: myApp.

In the other Pharo images I just send POST requests like this:

ZnEasy post: 'http://localhost:9090/store' data: (ZnEntity text: someData).

This code is working but I'm running into some trouble trying to port it to Gemstone. So far, I have loaded and tested my app in Gemstone (without changing anything), but the server part is giving me some headaches.

Right now i'm working with the gemstone shell in tODE. I tried executing there this line of code:

eval `(ZnServer on: 9090) start; delegate: myApp`.

After doing this, I can send post requests from the shell itself and it works, but when I try to send a request from a Pharo image I get a "Data received time out". However, when I send a POST request from the shell, all previous requests from the Pharo Images are executed and all sets of data are stored.

So, if I send a POST request from a Pharo image and immediately send a POST request from the Gemstone Shell, it works: both sets of data are stored and both responses are received.

But I would like it to work without having to send dummy post requests from the shell. I don't understand what goes wrong. Maybe I have to do things in a different way? I'm just starting to work with Gemstone and there are a lot of concepts that I don't quite get yet, but I'd really like to learn.

What can I do in order to make it work?

Thanks!

--
David Temnyk

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




--



--
David Temnyk

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Zinc Server in Gemstone

GLASS mailing list

David,

Mariano's code was close, but not quite correct:

run
(ZnServer on: 9090) start; delegate: myApp.
[true] whileTrue: [(Delay forSeconds: 1) wait]
%

The problem is that when control returns to the topaz prompt (or the tODE shell), the server process is  not running. Instead the client process (topaz or tODE) is waiting for input from the user. To run a server process in GemStone you must start your server in a forked process AND arrange to not return to the topaz (or tODE).

With a delay loop like the one above, your server should process all of the requests ...

The above code is a very simple zinc gem server ... as you work with GemStone more, you will probably find that you need to enhance the functionality of your "gem server" and I would recommend that you read the following document: "Getting started with Gem Servers"[1] to learn a bit more about the ins and outs or running gem servers with GemStone.

Dale

[1] https://github.com/GsDevKit/gsApplicationTools/blob/master/docs/gettingStarted.md#getting-started-with-gem-servers

On 11/22/2016 02:52 PM, David Temnyk via Glass wrote:
Hello Mariano, thank you for your answer.

I tried what you said but sadly I got the same results.

I can't understand why when I make a request from a Pharo Image nothing happens until I send another request from either the tODE shell or topaz...

I must be doing something wrong but I can't figure out what it is.

2016-11-22 17:30 GMT-03:00 Mariano Martinez Peck <[hidden email]>:
I am not sure about the following I will comment ... but... cannot it be that the `eval` uses the same gem as the one running tODE and that may cause some problems? Did you try running the 

(ZnServer on: 9090) start; delegate: myApp

but from a `startTopaz` ?

$GS_HOME/bin/startTopaz myStone -l 

Once inside topaz:

login
run
(ZnServer on: 9090) start; delegate: myApp
%



Cheers,


On Tue, Nov 22, 2016 at 4:27 PM, David Temnyk via Glass <[hidden email]> wrote:
Hi!

I'm trying to port some working Pharo code to Gemstone.

I have a small project which consists in sending some data from different Pharo images to another one that simply stores it in some object. In order to do that, I create a Zinc Server, make it listen on port 9090 and delegate the requests to my app, like this:

(ZnServer on: 9090) start; delegate: myApp.

In the other Pharo images I just send POST requests like this:

ZnEasy post: 'http://localhost:9090/store' data: (ZnEntity text: someData).

This code is working but I'm running into some trouble trying to port it to Gemstone. So far, I have loaded and tested my app in Gemstone (without changing anything), but the server part is giving me some headaches.

Right now i'm working with the gemstone shell in tODE. I tried executing there this line of code:

eval `(ZnServer on: 9090) start; delegate: myApp`.

After doing this, I can send post requests from the shell itself and it works, but when I try to send a request from a Pharo image I get a "Data received time out". However, when I send a POST request from the shell, all previous requests from the Pharo Images are executed and all sets of data are stored.

So, if I send a POST request from a Pharo image and immediately send a POST request from the Gemstone Shell, it works: both sets of data are stored and both responses are received.

But I would like it to work without having to send dummy post requests from the shell. I don't understand what goes wrong. Maybe I have to do things in a different way? I'm just starting to work with Gemstone and there are a lot of concepts that I don't quite get yet, but I'd really like to learn.

What can I do in order to make it work?

Thanks!

--
David Temnyk

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




--



--
David Temnyk


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Zinc Server in Gemstone

GLASS mailing list
Hello Dale!

Thank you for your help and your explanation! Now it works perfectly!

I will take some time to read that document in order to better understand about Gem Servers.


David


2016-11-22 20:27 GMT-03:00 Dale Henrichs via Glass <[hidden email]>:

David,

Mariano's code was close, but not quite correct:

run
(ZnServer on: 9090) start; delegate: myApp.
[true] whileTrue: [(Delay forSeconds: 1) wait]
%

The problem is that when control returns to the topaz prompt (or the tODE shell), the server process is  not running. Instead the client process (topaz or tODE) is waiting for input from the user. To run a server process in GemStone you must start your server in a forked process AND arrange to not return to the topaz (or tODE).

With a delay loop like the one above, your server should process all of the requests ...

The above code is a very simple zinc gem server ... as you work with GemStone more, you will probably find that you need to enhance the functionality of your "gem server" and I would recommend that you read the following document: "Getting started with Gem Servers"[1] to learn a bit more about the ins and outs or running gem servers with GemStone.

Dale

[1] https://github.com/GsDevKit/gsApplicationTools/blob/master/docs/gettingStarted.md#getting-started-with-gem-servers

On 11/22/2016 02:52 PM, David Temnyk via Glass wrote:
Hello Mariano, thank you for your answer.

I tried what you said but sadly I got the same results.

I can't understand why when I make a request from a Pharo Image nothing happens until I send another request from either the tODE shell or topaz...

I must be doing something wrong but I can't figure out what it is.

2016-11-22 17:30 GMT-03:00 Mariano Martinez Peck <[hidden email]>:
I am not sure about the following I will comment ... but... cannot it be that the `eval` uses the same gem as the one running tODE and that may cause some problems? Did you try running the 

(ZnServer on: 9090) start; delegate: myApp

but from a `startTopaz` ?

$GS_HOME/bin/startTopaz myStone -l 

Once inside topaz:

login
run
(ZnServer on: 9090) start; delegate: myApp
%



Cheers,


On Tue, Nov 22, 2016 at 4:27 PM, David Temnyk via Glass <[hidden email]> wrote:
Hi!

I'm trying to port some working Pharo code to Gemstone.

I have a small project which consists in sending some data from different Pharo images to another one that simply stores it in some object. In order to do that, I create a Zinc Server, make it listen on port 9090 and delegate the requests to my app, like this:

(ZnServer on: 9090) start; delegate: myApp.

In the other Pharo images I just send POST requests like this:

ZnEasy post: 'http://localhost:9090/store' data: (ZnEntity text: someData).

This code is working but I'm running into some trouble trying to port it to Gemstone. So far, I have loaded and tested my app in Gemstone (without changing anything), but the server part is giving me some headaches.

Right now i'm working with the gemstone shell in tODE. I tried executing there this line of code:

eval `(ZnServer on: 9090) start; delegate: myApp`.

After doing this, I can send post requests from the shell itself and it works, but when I try to send a request from a Pharo image I get a "Data received time out". However, when I send a POST request from the shell, all previous requests from the Pharo Images are executed and all sets of data are stored.

So, if I send a POST request from a Pharo image and immediately send a POST request from the Gemstone Shell, it works: both sets of data are stored and both responses are received.

But I would like it to work without having to send dummy post requests from the shell. I don't understand what goes wrong. Maybe I have to do things in a different way? I'm just starting to work with Gemstone and there are a lot of concepts that I don't quite get yet, but I'd really like to learn.

What can I do in order to make it work?

Thanks!

--
David Temnyk

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




--



--
David Temnyk


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




--
David Temnyk

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass