Connecting to Docker Container Network from the Client Side - php

I have two containers, a php server serving a laravel application and a spring boot application running a websocket server. My architecture was to connect the two containers using Docker Networking and have the Laravel container port published to the outside. The laravel application is pretty much all front end, and on one page is a chat room using websocket. I tried to connect the chat room to the Spring Boot websocket container name (Docker network) but I feel like because this request is coming from the client this is not possible? I am using the container name (domain name) as a URL on the javascript file that is being served by the php server. Would the only way to make this work is publish the Spring Boot port as well on a public server and replace the websocket url with a public url?

Additional info like docker-compose or commands you are running would also be helpful.
But from what I see, the issue probably is that the requests are coming from the client which means that they can't access the actual service since it's not available publicly...
You should probably make that service available as well by mapping the necessary ports to your host machine or create some proxy server to pass the requests to the websocket

Related

Running multiple listening scripts on different ports in laravel

I have a project to make a chat app between mobile and java clients with my laravel website acting as a mediator for communication between them. I am new to laravel, so maybe some of the terms may not be correct.
So basically the problem is to run a websocket server on one port and simultaneously run a xmpp server to communicate with fcm/android on another port.
Individually they both are working fine on commands set by me.
But I am not able to run them simultaneously.
How should I go about it.
Secondly I don't know if it is fine to run two endless scripts on a simple website server.
I running websocket with Laravel too.
And I use Swoole to drive it.
https://github.com/swooletw/laravel-swoole

Verify Apache availability behind Azure Balancer for each VM

Status:
2xA2 Azure VM with WAMP, behind Load Balancer
endpoint monitoring set
Question:
How do i check the Apache availability for each VM (as port 80 is now balanced and i cannot individually check a machine)?
I need to check the response via a php script to be able to automatically deploy further custom actions.
Is there a way to manually check (via php, or online service) a probe.html(or specific file for each machine) that reside on each machine, in any way?
If the two VMs exist on a private Azure VNET you could add a third machine to that VNET from which to perform the monitoring and then use the private IP address of each machine as your test endpoint.

How can I access socket through Openshift

I register in the Openshift.com and create a catridge. But when I need to deploy Mosquitto, a MQTT Server, which is accessed through tcp or ssl protocol, and I need visit from public IP.
Does Openshift just redirect http/https protocol through 80/443 port to 8080?
Is it possible to use socket communcation in Openshift?
I have created two applications in Openshift, one for push and the other for web deployment, and I stopped the apache service in order to let the mosquitto service listen to 8080. But only if I send post request in https protocol, It can access to the server for a while and disconnect.
I think this might point you in the right direction https://www.openshift.com/blogs/paas-websockets.
To save some readings from the readers, the steps involved in niharvey's answer:
Create a diy app in your openshift account.
Git checkout the code.
Add a websocket app of your own choice that would bind to $OPENSHIFT_DIY_IP:$OPENSHIFT_DIY_PORT.
Modify the action hooks for starting and stopping your app. Push the code.
From the client, connect to port 8000 for ws:// or 8443 for wss://, by your app url.
Just verified these steps do work as expected.

Create and consume web service on local machine by using WAMP

Is it possible to create an environment on local machine( i.e. localhost) where we can create and consume web service using PHP?
Is there any flow to create a web service like environment on localhost?
I would like to create an environment on localhost for web services where local machines, on intranet, get connected to main server (here again it's local machine) and can consume web services.
Like on internet we have Web Servers from where we can create and consume web services, Can we do the same on localhost?
Edit:
I am using WAMP with
PHP 5.3 Apache 2.* MySQL 5Windows 8
It is easy to create a local web service. You will need a local web server (like IIS or xampp) to execute PHP locally.
Access you PHP application in your browser using http://localhost/<yourApp>.php and provide any webservice at a local URL as well, e.g. http://localhost/<yourService>.php. Your application can then access the webservice using the local URL.
This works both for REST or SOAP-style services.
EDIT: Your edit shows that you already set up a local environment to develop and test webservices. You should really be more specific in your question, maybe you are looking for a tutorial to create web services with PHP in genereal. If so, Google will be your best friend: https://www.google.de/#q=create+web+service+using+php+tutorial

Socket.IO integration with Apache2 for live update calendar

I'm trying to build a calendar with live update using Socket.IO Websocket. I managed to get the Socket.IO server running on port 8181 but my calendar.php is managed via apache on port 80.
What I'm looking to do is to use my calendar.php with apache and at the same time connect to my Socket.IO server on port 8181 (or bind it to port 80 with apache but that seem to be pretty complicated, I tried back proxy but didn't work) to receive updates when someone edited a event in the calendar. My events are stored in a SQL database.
So is there a way to use Socket.IO on port 8181 in a php page served by apache on port 80?
Thanks!
I'm not sure I understand your issue. Once the page is served by PHP on port 80, you would connect to your socket.io server on 8181 in the simplest set up.
And from then on you wouldn't need to interact with php again since you'd probably be sending messages to your socket.io server to process.
For load balancing socket.io, I think you can use HAProxy and I think LearnBoost has an alternative on Github also. I actually haven't gotten to this step with my app yet, so I can't give too much info here.
But yeah, your socket.io server should receive, process and send messages. You can also use redis for Pub/Sub if you have multiple instances of socket.io running.
There is a node module for an asynchronous MySQL driver that will allow you to interact with your Database directly. I'm using MongoDb in my app, so I've never used the MySQL modules.
I guess alternatively, you could use your PHP server as a web service and your socket.io server could interact with it, but I imagine it would be slow to do it like that.
Hopefully that clears things up. Seems like your set up will already work in a dev environment.

Categories