Is it possible to open a WebSocket to client localhost? - websocket

I've to design a solution that permits to read real-time data generated by local sensors through a remotely-hosted web application.
The design is still work in progress: the sensors' data could be handled by a windows application/service installed on the client machine, or by some external hardware (like a raspberry) located on the same network of the client machine.
Now, I'm very new to WebSockets, but they seems exactly what I need for providing real-time data via browser.
My question is: can a remote web application open a WebSocket to a server that is located on the same local network which the client belongs to?
Is solution B possible? How can I achieve that?
For example, I'd like the server to be located on the client localhost. Sensors would send data to the local windows service, and the web application would show them by opening a WebSocket to localhost (client localhost, not server localhost!).

Well, I did some testing and the answer is yes, it is possible.
Test setup:
A web page hosted on a remote server, with a WebSocket client which connects to 'localhost'.
WebSocket server running on my pc.
It worked.

Related

HTTPS and Secured Websockets clarification

We have a web application that is required to run on HTTPS. We started to use a third party control that uses Websockets to connect to a windows service that will be running on the user computer. This page states that websockets should not be used in a mixed content environment. Is this security consideration still applies in this case (the websocket connection is not trying to connect to the same server that handled the https request)? If so, why would a websockets to a localhost would need to be secured? Isn't this just added complexity for no reason?

Using Squid to forward traffic to specific IP address

I have an issue I can't seem to figure how to solve. I am thinking of using Squid for this but not 100% sure how to configure. A developer is writing a script that will request an XML file from a secure web server.
The script will live in a cloud-based application and will send the request for this XML file to the web server, the script will then translate the XML file content into readable data using API calls and presented to the user in the application.
The problem is the following:
The application server (A) its load balanced and the IP address may not always be the same. We do not own this app server only have access to APIs
The Web server (B) that owns the XML is behind a firewall and it has to specify the incoming IP address allowed to access this content
I am thinking I would have to configure reverse proxy on Squid that will receive the script/request from any IP address (preferably from the application servers only) and would have to forward the exact request to the IP address of the Web server that owns the XML file.
This means that I would have to specify the IP address of the proxy server rather than the web server in the script and somehow allow the proxy server to know it needs to forward it to the web server.
I'm not sure how to do this securely since in this scenario as ANY external IP address coming the proxy server will be forwarded over.
(A) App server ======> Squid Proxy =======> (B) Webserver
I hope this makes sense thank you so much in advance for your help.

How do I send a HTTP requests from a device to a server which runs in the testrunner of Xamarin Test Cloud

I am using Xamarin.UITest for automated tests of an Android and iOS application. This app makes some HTTP requests to a webserver.
For testing purposes and to easily respond with the needed data for the test case, I start a temporary HTTP server (I am using HttpListener) in the test and adjust the application, so it makes the requests to this temporary server.
When I run the tests local on my devices and simulators, everything works.
When I run the tests in the Xamarin Test Cloud, I can not get a connection to the HTTP Server. Url in that case would be http://executionhost11.prod:/...
Is this use case possible in the Xamarin Test Cloud?
Do I have to use some specific ports (I tried 8081 and 7103)?
I was informed by the Xamarin Support, that my usecase is not supported by Xamarin Test Cloud.
Between the devices and the executor are firewalls in place, which prevent the connection from the device to the test executor.
Recommended models are:
spin up a cloud hosted http server
start the http server on the device
The requirements for connecting to Test Cloud are described in the Submitting Tests to Xamarin Test Cloud guide. Specifically it says:
Internet access to the Test Cloud web servers is required. Firewalls should be configured to allow traffic to the Test Cloud servers at the following IP addresses:
195.249.159.238
195.249.159.239
The Test Cloud servers require port 80 and 443.
Android applications must request the INTERNET permission in AndroidManifest.XML.
The information here is true whether you're uploading tests (which is the main scenario described in the guide); and remains unchanged when communicating with a server, in that your server will need to access those IP addresses.

How to performant connect a FTP Server to a Webdav Server?

I have implemented a webdav directory in PHP using Sabre DAV, for my website (Application Server Webinterface).
For this Website I am writing now an TCP Socket using C#, which is running on another server (actualy it is in the same datacenter, but for theoretical sake, it is on the other hemisphere).
The Socket actualy is a service, which can start and stop applications (gameserver in this case). I also have implemented a FTP Service in this socket too (for data transfer).
My Goal:
I want to connect my Web Dav to the FTP-Server of my socket, which means File Listening, Download, Upload. The usecase should be, that a user only connect to a single service. Imagine, my socket is running on more then one server.
If i would implement this with my current know how, i would do it this way:
User Request Web Dav Directory
Server make a file listening of the FTP Server
The file listening is added dynamicly to the Web Dav Directory
Now the user open the directory, and want to download the file:
Web Dav Server request the file from the Ftp server
Web Dav Server provide the downloaded file
Web Dav Server delete the provided file
On the other direction, the WebDav Server will accept a file, and upload it then to the FTP Server.
If the servers are not in the same datacenter, this cost traffic. Anyway, i think it takes some time, if the data are binrary instead of textbased configs. Also, the client side progress bar will not notice, if the download to the webdav server / upload to the ftp server is processed (the user possible think nothing happens).
I hope i have successful communicated, where my problem is.
So how can I implement this, without delegate an upload/download from one server to another? Is this even possible?
Bonus: Would a solution like WebDav to Webdav or FTP to FTP provide a better way of implementing it?
Easy way to achieve this is to have a third party software like webdrive to map the ftp server contents to a drive letter. Then point the webdav server to this drive. Windows also provides option to map a webdav/ftp URL as a drive letter so that the application can access it as if its a local drive.

Load test Service layer with LoadRunner thru Spring Remote

I have N-tier application; the presentation layer remote to the service layer through Spring Remote over HTTP. The enterprise uses Mercury LoadRunner for load testing. My question is how can I test the Service Layer by itself using LoadRunner and Spring Remote?? I looked around and could not find documentation on how to do so. Kindly share your experience. Thanks!
It's been a long time since I used this method, so I don't know if it will still work.
Record a web script and look in your proxy settings, you'll see that the web browser is pointing at localhost on port 7777. Set the Spring Remote machine's proxy server to be your VUGen machine on port 7777, it should record without problems, but you'll have to tweak your runtime settings to properly emulate a server.
If this doesn't work then you'll have to record the network traffic with a packet capture library (winpcap, pcap or Wireshark) and write your scripts by hand. This won't be hard if you understand HTTP.

Resources