Hi All, I have completed the NGINX and Websockets integration using WSO2 AS 5.3.0 Alpha. I have included the code in github at [1]. The websocket server implemented using JSR 356 and the jax-rs service are both deployed in the AS.
By using the curl client I am able to send and display messages in the browser. The *complete NGINX configuration* is as follows. Create a file named astest.com in /etc/nginx/sites-available. The content of astest.com should be as follows. *upstream wso2.as.com <http://wso2.as.com> { ip_hash;* * # WSO2 AS address is xx.xxx.xxx.xxx* * server xx.xxx.xxx.xxx:9763; keepalive 8;}# the nginx server instanceserver { listen 80; server_name as.wso2.com <http://as.wso2.com> ; access_log /var/log/nginx/nginxtest.log; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://wso2.as.com/ <http://wso2.as.com/>; proxy_redirect off; } }* Execute the following commands. *cd /etc/nginx/sites-enabledsudo ln -s /etc/nginx/sites-available/astest.com <http://astest.com> astest.com <http://astest.com>* The above creates a symbolic link of the nginx server instance in /etc/nginx/sites-enabled. In order for the NGINX server instance to take effect I also appended the following in the /etc/hosts file in my local machine. *# nginx virtual servers* *# Local machine ip is xx.xxx.xxx.xxx* *xx.xxx.xxx.xxx as.wso2.com <http://as.wso2.com>* Execute the following command. *source /etc/hosts* By using the curl client now we can successfully send and display messages to the browser using the following command where the url is of the following format "http://as.wso2.com:80/FirstJaxRsService/{message}". Note that in order for the browser to accept messages first a connection needs to be opened. *curl http://as.wso2.com:80/FirstJaxRsService/hello <http://as.wso2.com:80/FirstJaxRsService/hello>* [1] https://github.com/SabraO/WebsocketNginxintegration Thanks and Regards. On Wed, Jul 1, 2015 at 10:47 PM, Dimuthu Leelarathne <dimut...@wso2.com> wrote: > Hi Sabra, > > Yes. This looks good. Please proceed. > > thanks, > dimuthu > > > On Tue, Jun 30, 2015 at 10:01 AM, Sabra Ossen <sabra...@gmail.com> wrote: > >> Hi All, >> >> During implementation an issue was raised on using the curl client to >> send messages to the echo server. Therefore in order for the Java echo >> server to be able to accept messages from the curl client I have included a >> JAX- RS web service in between. >> >> I have attached a diagram showing the updated design for the POC. >> >> Regards. >> Sabra. >> >> On Fri, Jun 19, 2015 at 2:13 PM, Sabra Ossen <sabra...@gmail.com> wrote: >> >>> Hi Manjula, >>> >>> Okay, then I will focus on step 1 and 2. And I will also check if the >>> latest AS release supports web sockets, failing which I will proceed with >>> AS 5.1.0. >>> >>> Thanks for the help. >>> >>> Regards. >>> >>> On Fri, Jun 19, 2015 at 11:26 AM, Manjula Rathnayake <manju...@wso2.com> >>> wrote: >>> >>>> Hi Sabra, >>>> >>>> These notes cover most of the items of we discussed. >>>> IMO, we do not need to consider step 3 at this point of POC. It is more >>>> related to AF Wall functionality. After completing POC, we will have a demo >>>> and discuss next steps. >>>> >>>> I was checking if latest application server supports web sockets but >>>> for AS 5.1.0, I could find some samples at [1]. >>>> >>>> [1]. >>>> https://svn.wso2.org/repos/wso2/carbon/platform/tags/4.1.0/products/as/5.1.0/modules/samples/common/webapp/src/main/java/websocket/ >>>> >>>> thank you. >>>> >>>> >>>> On Fri, Jun 19, 2015 at 11:18 AM, Sabra Ossen <sabra...@gmail.com> >>>> wrote: >>>> >>>>> Hi All, >>>>> >>>>> Currently in AF the FE (AF Wall) polls the BE (Social Component) to >>>>> identify and display notifications. >>>>> >>>>> The method proposed below is for $subject. The PoC for $subject is as >>>>> follows. >>>>> >>>>> *1) The curl client pushes data to the Java Echo Server (Hosted in >>>>> WSO2 AS) which then writes to the client browser through the web socket.* >>>>> I have attached a screen shot of a diagram showing the design. Nginx is >>>>> used to emphasize on load balancing and as a proxy. >>>>> >>>>> 2) With the completion of the above step then we move on to the next >>>>> step of *creating a listener for the Social API replacing the Java >>>>> Echo Server* and then port the code to AF. >>>>> >>>>> 3) One issue raised during discussion of $subject was the >>>>> *rendering of relevant content in a switch happening between two >>>>> pages.* >>>>> For example, the curl client pushes msg1 to page1 and msg2 to page2. >>>>> During this switch the same web socket connection should be used >>>>> rather than restarting a new connection. >>>>> >>>>> @Dimuthu and Manjula, Please let me know if I have missed anything and >>>>> any further opinions you have on $subject. >>>>> One clarification I require is that should the point mentioned in step >>>>> 3 be completed, after step 1 or after completion of steps 1 and 2. >>>>> >>>>> Thanks in advance. >>>>> >>>>> -- >>>>> Sabra Ossen <http://lk.linkedin.com/in/sabraossen> >>>>> Undergraduate | Department of Computer Science and Engineering >>>>> University of Moratuwa >>>>> Sri Lanka >>>>> >>>> >>>> >>>> >>>> -- >>>> Manjula Rathnayaka >>>> Software Engineer >>>> WSO2, Inc. >>>> Mobile:+94 77 743 1987 >>>> >>> >>> >>> >>> -- >>> Sabra Ossen <http://lk.linkedin.com/in/sabraossen> >>> Undergraduate | Department of Computer Science and Engineering >>> University of Moratuwa >>> Sri Lanka >>> >> >> >> >> -- >> Sabra Ossen <http://lk.linkedin.com/in/sabraossen> >> Undergraduate | Department of Computer Science and Engineering >> University of Moratuwa >> Sri Lanka >> > > > > -- > Dimuthu Leelarathne > Director & Product Lead of App Factory > > WSO2, Inc. (http://wso2.com) > email: dimut...@wso2.com > Mobile : 0773661935 > > Lean . Enterprise . Middleware > -- Sabra Ossen <http://lk.linkedin.com/in/sabraossen> Undergraduate | Department of Computer Science and Engineering University of Moratuwa Sri Lanka
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev