How to access localhost or 127.0.0.1 on a Windows machine from Ubuntu Production Server? - windows

I need to fetch some data from a biometric device connected to the customer's PC and return it back to my production server. I'm using a Mantra MFS100 Biometric Device to capture biometric data of the user. According to Mantra's document the biometric service will be running in 127.0.0.1. I'm able to utilize different endpoints and fetch the data required locally(using pycharm IDE windows) but when trying from my production Ubuntu Server it does not work.
The biometric service will be running on port range 11100 - 11120. To use the service I need to discover the port on which the service is running.
Code to discover the service:
import requests
for port in xrange(11100, 11122, 1):
response = requests.request('RDSERVICE', 'http://localhost:%s' % str(port), headers=headers, data=data)
if response.status == "READY":
device_port = port
if port == 11121:
print "Fingerprint device is not connected"
If the service is READY, I can move on to capture the device data:
import requests
response = requests.request('CAPTURE', 'http://localhost:%s/rd/capture' % device_port, headers=headers, data=data)
print response.text
This works when I'm trying from Local Windows IDE and endpoint as Localhost or 127.0.0.1 but does not work when I try from Ubuntu Server. When trying from the Ubuntu Server I get the following error:
HTTPConnectionPool(host='127.0.1.1', port=11100): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f677d12cf10>: Failed to establish a new connection: [Errno 111] Connection refused',))
I also tried passing the user's ip as the endpoint to no avail:
import requests
import socket
ip_address = socket.gethostbyname(socket.gethostname())
response = requests.request('CAPTURE', 'http://%s:%s/rd/capture' % (ip_address, device_port), headers=headers, data=data)
How can I access Window's Localhost from Ubuntu Server(NGINX) in Python?
Edit:
This is the request, response data from the document:
Request:
RDSERVICE * HTTP/1.1
HOST: http://127.0.0.1:[port]
EXT: APP_NAME
Response:
HTTP/1.1 200 OK
CACHE-CONTROL:no-cache
LOCATION:http://127.0.0.1:<rd_service_port>
Content-Length: length in bytes of the body
Content-Type: text/xml
Connection: Closed
<RDService status="READY|USED|NOTREADY|..." info="provider info for display purposes">
<Interface id="CAPTURE" path="/rd/capture" />
<Interface id="DEVICEINFO" path="/rd/info" />
</RDService>

I solved this by executing the logic as ir.actions.client action with Javascript instead of Python. I'm able to access Localhost when I execute the logic as a client action.

Related

Domain name is not loading the response but localhost works

I am using mountebank for mocking responses which is running in Docker on port 2525. Stubs are created on port 443. The response is successful when I use localhost but not with the domain name. The domain names are redirected in hosts file.
OS: Windows 10 Pro
Failed to hit mock with the domain name
Hosts File
Postman console error
Wireshark log for the domain name
Successful localhost logs which uses IPV6 internally
Postman Successful Response
Successful response console details
Wireshark logs for localhost
This issue is resolved by redirecting all domain names to ipv6 address.
Also listening to ipv6 address using netsh command. Referred to Can't access 127.0.0.1
netsh http add iplisten 127.0.0.1

grpc-go over https: failed rpc error: code = Unavailable desc = transport is closing:

Note: This is running in containers in Kubernetes.
I have successfully done this very short description: https://knative.dev/docs/serving/samples/grpc-ping-go/
Success:
2019/05/08 13:43:56 Ping got hello - pong
2019/05/08 13:43:56 Got pong 2019-05-08 13:43:57.646935391 +0000 UTC m=+1.661567121
But if I run through 443 from a Gateway on knative setup for https, it does not work:
docker run -ti --entrypoint=/client docker.io/{username}/grpc-ping-go \
-server_addr="${SERVICE_IP}:443" \
-server_host_override="${SERVICE_HOST}" \
-insecure
2019/05/08 13:50:28 &{0xc00012e000}.Ping failed rpc error: code = Unavailable desc = transport is closing:
The client code from the sample, and the server code.
The server is not listening for tls, but the connection to the server is over https.
Just to make sure, I know the https is worning from a simpel hello-go text reply.
In your server code, you are not listening on port 443, so this is most likely the reason your example isn't working.
If you want to keep using http and not https, then your code is working just fine.
If you want to get it working with TLS, this overview is a pretty good one.
To get port 80 to redirect to port 443 (I highly recommend it if you are using https), see this SO post.

Filezilla - can't access folder when connecting with other computer using ip adress but works localhost

When I am connecting using localhost on the computer the filezilla server lies on it works perfectly fine, but when I connect with IP-Adress (It is port-forwarded correctly, im 100% sure of that) this happens:
Status: Connecting to **.**.**.**:800...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Status: Logged in
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/" is current directory.
Command: TYPE I
Response: 200 Type set to I
Command: PASV
Response: 227 Entering Passive Mode (**,**,**,**,***,***)
Command: MLSD
Error: The data connection could not be established: ECONNREFUSED -
Connection refused by server
Response: 425 Can't open data connection for transfer of "/"
Error: Failed to retrieve directory listing
When this happens, it's usually a firewall configuration problem.
Besides a control connection, FTP also uses a data connection on a different port that needs to be assigned before data trasfers.
This means that you must open ports on your firewall to allow data transfers and, of course, you should make FileZilla Server aware of that.
For passive mode transfers, you should set a range of ports from the window below:
Of course those ports should be open at the firewall too. A longer discussion can be find here.

How to properly configure a FTPconnection with Windows Azure Server.?

I'm new to Windows Azure Server configurations, and I'm trying to configure the FTP Connection. But when I access the Server with FileZilla it doesn't work. What am I doing wrong here?
I'm using IIS with FTP Server Roles installed.
Following is the error log from FileZilla
Status: Resolving address of AZR-SRV-map01.cloudapp.net
Status: Connecting to 52.187.64.207:990...
Status: Connection established, initializing TLS...
Status: Verifying certificate...
Status: TLS connection established, waiting for welcome message...
Status: Logged in
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/" is current directory.
Command: TYPE I
Response: 200 Type set to I.
Command: PASV
Response: 227 Entering Passive Mode (52,187,64,207,195,237).
Command: LIST
Response: 150 Opening BINARY mode data connection.
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
Status: Disconnected from server
I also tried the following steps in configuring the FTP Connection...
Here the endpoints have being configured from the Azure Portal.
This is how I published the FTP Site
Configured the FTP Firewall Support with the Azure Server Public IP
And enabled the firewall outbound and inbound rules..
After completing all the steps, I restarted the Microsoft FTP Service, but the problem still exists.
For now, we can't configure a active mode FTP on Azure VM. we should configure data channel port range in FTP Firewall Support, FTP work in passive mode. For example, we can use 10000-10010 ports as the data channel port range. Also, we should add ports to VM's endpoints and add then to VM's firewall inbound rules.
By the way, although the windows firewall seems to allow all traffic that’s required, we also need to enable stateful FTP filtering on the firewall:
netsh advfirewall set global StatefulFtp enable
Then restart the FTP windows service and we should be up and running:
net stop ftpsvc
net start ftpsvc
Here a case similar as you, please refer to it.

Connection to FTP server sometimes works and others not

I have a ubuntu server (on Azure) running proftpd, when I try to connect to that server using FileZilla sometimes it works, sometimes it doesn't (usually it doesn't work at first... and I need to keep trying several random times before it works... and once it does it works for good...), now this is the error I receive it FileZilla logs:
Status: Resolving address of ftp.myserver.com
Status: Connecting to xx.xx.xx.xx:21...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Command: USER my_user
Response: 331 Password required for my_user
Command: PASS *******
Error: Connection timed out after 20 seconds of inactivity
Error: Could not connect to server
Status: Waiting to retry...
Status: Resolving address of ftp.myserver.com
Status: Connecting to xx.xx.xx.xx:21...
Status: Connection established, waiting for welcome message...
Response: 220 ProFTPD 1.3.5a Server (Debian) [xx.xx.xx.xx]
Command: AUTH TLS
Response: 500 AUTH not understood
Command: AUTH SSL
Response: 500 AUTH not understood
Status: Insecure server, it does not support FTP over TLS.
Command: USER my_user
Response: 331 Password required for my_user
Command: PASS *******
Error: Connection timed out after 20 seconds of inactivity
Error: Could not connect to server
and this is what I see in proftpd logs:
2016-08-09 10:26:37,263 FTP proftpd[33961] 10.0.0.6 (yy.yy.yy.yy[yy.yy.yy.yy]): USER my_user: Login successful.
2016-08-09 10:26:37,264 FTP proftpd[33961] 10.0.0.6 (yy.yy.yy.yy[yy.yy.yy.yy]): FTP session closed.
2016-08-09 10:26:37,468 FTP proftpd[33970] 10.0.0.6 (yy.yy.yy.yy[yy.yy.yy.yy]): FTP session opened.
I don't know why the server closes and reopens the connection after the login but I am no FTP expert...
Any thoughts on how to fix this?
Edit:
This is the content of proftpd.conf file
There are multiple possible causes for a delay at login time with ProFTPD. The most common causes are the mod_delay module (see its FAQ), or IdentLookups or UseReverseDNS.
However, since your delay happens after the PASS command has been sent, that rules out the IdentLookups or UseReverseDNS directives, as those pertain to the initial connection establishment, before any commands are sent.
Per discussion with the reporter, any latency added by mod_delay was ruled out. That leaves PAM, which, depending on the configuration (e.g. in /etc/pam.d/ftp) and the modules used, can add its own latency (over which ProFTPD has little control). To disable ProFTPD's use of PAM, you would use the following in the config:
<IfModule mod_auth_pam.c>
AuthPAM off
</IfModule>
The reporter mentioned that disabling the use of PAM did indeed remove the delay -- thus pointing out that one of the PAM modules was the root cause.
Hope this helps!

Resources