I have been trying for ages and can't figure it out, I hope you can help me.
I have my SQL database running as well as FastApi.
FastAPI is running on: http://127.0.0.1:8000
<- as seen here
And it works perfectly when testing on OpenApi as shown here.
I have my flutter app making the the following get request:
Future MakeGetProductRequest() async {
Uri url = Uri.parse('http://localhost:8000/items?page=1&number=5');
var response = await http.get(url);
return response;
}
When running the app on a physical device through USB-debugging, I get the following Error:
Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 34214
Full console error here
NOTE: I am running this on a physical device not an emulator!
It won't work on the loopback address. Your address 127.0.0.1 is not accessible on the flutter device.
To connect both of them, you will have to run FastAPI on 0.0.0.0 like this:
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
The above code will make your local IP available over the LAN. Just make sure your phone and PC are connected to the same WIFI network.
To get your PC's IP address, run this in command prompt:
ipconfig
And you will get output like this:
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
IPv4 Address. . . . . . . . . . . : 192.168.29.82
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.29.1
You can see my IPv4 Address is 192.168.29.82 so, to access FastAPI from my flutter code, I will have to connect to http://192.168.29.82:8000
Related
I am developing an app consisting sailsjs in backend and ng-boilerplate in frontend. In my dev machine(64 bit ubuntu) is all working. But when I put my app for testing purposes into a 32bit debian machine, sailsjs is refusing connection on address
http://localhost:1337/blog.
When I replace localhost with hostname of my debian-machine, like that:
http://debian:1337/blog, all is going to work.
This is error message in browser console:
GET http://localhost:1337/blog net::ERR_CONNECTION_REFUSED
This is content my /etc/hosts file:
127.0.0.1 localhost
#127.0.0.1 debian
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters</pre>
This is content of my /etc/hostname:
debian
Could someone solve this mystery?
So, I add some things:
/config/env/development.js:
module.exports = {
models: {
connection: 'PeeterMongodbServer',
migrate: 'alter'
}
};
My /config/http.js is just empty, it means as it was when I have sails installed.
Try ifconfig or ipconfig as applicable
FOR e.g inet 192.168.1.64
Also update your etc/hosts file
$ cat /etc/hosts
127.0.0.1 localhost
192.168.1.64 debian
Pls ensure this is tabbed between IP address and hostname.
On running ngrok and going to the suggested url, i get
GET /favicon.icon 404 error in ngrok.
In which folder does ngrok search for the favicon.ico file ?
How do i fix this ?
Very new to ngrok. Do help me out
Thanks in advance
I ran into a similar problem with URIs from ngrok being served as 404s.
I have a local Apache, PHP and MySQL stack setup on macOS using *.dev domains.
So in my case, I needed to set the host-header option in ngrok to match the hostname of the virtual host Apache was configured for.
Here's the relevant part of my Apache virtual host configuration:
<VirtualHost *:80>
ServerName example.dev
ServerAlias www.example.dev
...
UseCanonicalName Off
</VirtualHost>
The necessary ngrok arguments to tunnel requests to my private development domain were:
$ ngrok http example.dev:80 -host-header=example.dev
What ngrok do is,make tunnels to localhost.That allows you tunnel requests from Internet to your local machine.
You can see following details after running : ngrok http 8888
Tunnel Status
online
Version 2.0.19/2.0.19
Web Interface http://127.0.0.1:4040
Forwarding http://299954c1.ngrok.io -> localhost:8888
Now all the data intended for 'http://299954c1.ngrok.io' url which is publically accessible will come to your local machine at port 8888
You need to have some server running on your local machine at port 8888 which can serve 'favicon.icon' static file
If you are able to get icon by hitting : localhost:8888/favicon.icon in your browser, You will surely get it from http://299954c1.ngrok.io/favicon.icon
I pulled this SOLR docker image and then followed the instructions to run it.
docker run -d -p 8983:8983 -t makuk66/docker-solr
Typing in docker ps yielded
1197d246f0e3 makuk66/docker-solr:latest "/bin/bash -c '/opt/ 50 minutes ago Up 50 minutes 0.0.0.0:8983->8983/tcp suspicious_sinoussi
So I know it's running.
In order to connect to it I know I can't use localhost because it's running on the virtual machine. So I used ipconfig which yielded:
Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::cd9a:3e57:6d13:de3b%19
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Ethernet adapter VirtualBox Host-Only Network #2:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::1d62:c4b5:9436:518e%27
IPv4 Address. . . . . . . . . . . : 192.168.59.3
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
However when trying to connect to either of these IPs: 192.168.56.1 or 192.168.59.3 with and without the port :8983 specified I get
Google Chrome's connection attempt to 192.168.59.3 was rejected. The website may be down, or your network may not be properly configured.
How can I properly connect to the SOLR process running on docker?
Turns out I was over complicating the debugging.
When Boot2Docker first starts up it prints the message:
IP address of docker VM:
192.168.59.103
This IP allows you to access the SOLR instance.
The command:
boot2docker ip
Also lets you know what this IP is.
Using Nginx, I'm getting the error:
Error 502 - Bad Request
The server could not resolve your request for uri: http://domain.name/file/path
Oddly, I only get this error when my phone is using data from my cell carrier. The server serves everything just fine when I am using my phone on Wi-Fi or when I'm using a desktop computer. It even works when I am using my iPad conneted to my phone via Wi-Fi with my phone acting as a mobile hotspot.
The 502 error code suggests that there's an issue with reverse proxying or serving requests with php-fpm. I'm doing neither of these.
Because this error is happening only under specific circumstances, I'm thinking it has to be something with the request my phone is sending. (Nexus 5, Chrome, Android Lollipop)
My nginx.conf and other configuration files are passing tests. I used:
sudo nginx -t
and it said "the configuration file syntax is okay" and "configuration file test is successful."
What could be going on?
After tripple-checking my Nginx configuration, I had the idea to look at all tcp activity on port 80 of my server.
I installed tcpdump:
sudo apt-get install tcpdump
Then ran it, looking only for port 80 tcp traffic:
sudo tcpdump 'tcp port 80' -i eth0
I noticed that all other traffic was just 'IP', but when I sent a request from my phone, it was 'IP6'.
My server wasn't ipv6 enabled, but that's an easy fix with an additional listen directive:
listen [::]:80;
I've trouble in connecting to a wss secured socket server via google appengine frontend with managed VM support.
buy default google exposes only port 8080 in docker image google/nodejs-runtime, Even if expose port 8443 in Dockerfile like below i can connect only to http://localhost:8080 not https://localhost:8443
FROM google/nodejs
WORKDIR /app
ADD package.json /app/
RUN npm install
ADD . /app
EXPOSE 8443
CMD []
ENTRYPOINT ["/nodejs/bin/npm", "start"]
Still i can see port 8080 include in the container
"/nodejs/bin/npm start 8443/tcp, 0.0.0.0:8080->8080/tcp
If i log in to my managed vm instance and run the container image with
docker run -d -p 8443:8443 nodejs.default.wss-check:latest
and try
$curl https://localhost:8443
I get curl: (60) SSL certificate problem: unable to get local issuer certificate, It looks like its connecting but i've to use realdomain name
I've created a issue in github aswell https://github.com/GoogleCloudPlatform/appengine-nodejs-quickstart/issues/13, but not that helpful.
Same set up works like a charm in normal compute instance. but it doesn't auto scale.
Any help on this issue will be appreciated.
The reason you can't curl to https on localhost (curl: (60) SSL certificate problem: unable to get local issuer certificate) is because "localhost" is unknown to any CA. You need to run curl -k https://localhost:8443 to get it to ignore the lack of a certificate for localhost.
Looks like currently Google Managed VM supports Websocket connection only on JAVA
Even if you try websocket connection on with nodejs on GMV it defaults to polling transport. if you wanna see this in live you can use set socket transports, deploy to live and look in to console- network and see which transport its using!
socket.set('transports', [
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
We have to wait untill google implements websocket support in Managed VM. If anyone get this working on GMV, Please comment here :)