I am using Flutter Web and want to setup the development server for multiple devices.
I'm currently running the server like this:
flutter run -d web-server --web-port 5000
This works for http://localhost:5000 but when I try to access the server from http://127.0.0.1:5000/ even on the same machine it doesn't work.
How can make the server accessible from any device under the same network without building the app?
NEW ANSWER
Cloudflare should enable you to make a tunnel to your localhost.
On linux you can:
Install Cloudflare
Create a tunnel which point to localhost:5000 with cloudflared tunnel --url http://localhost:5000/
Use the given address to access your local development website from anywhere
Note that this is still slow. I would say it's good enough if you need to check on other devices once in a while but not if you want to develop like you would with hot reload.
OLD ANSWER (This seem to be really slow for an unknown reason)
You should look into something like ngrok.
On linux you can:
Install ngrok: sudo apt install ngrok
Create a tunnel which point to localhost:5000 with ngrok http 5000
Use the given address to access your local development website from anywhere
You need to add --web-hostname 0.0.0.0;
flutter run -d web-server --web-hostname 0.0.0.0 --web-port 5000
This tells it to listen on all addresses.
For me hostname 0.0.0.0 does not work (it works with PHP but not for Flutter)
flutter run -d web-server --web-hostname 0.0.0.0 --web-port 5000
It works when using actual local IP number of my machine
Related
I like to use scrapyRT to connect all my scraper spiders to the Angular front-end.
The documentation recommends to run in it in production as follows:
docker run -p 9080:9080 -tid -v /home/user/quotesbot:/scrapyrt/project scrapinghub/scrapyrt
This will expose port 9080 to the outside world.
I'm concerned about the safety of this.
How can I properly secure this to avoid bots visiting the end points?
If Scrapyrt is running on the same machine as your frontend, you could make Scrapyrt listen only on localhost:
docker run -p 9080:9080 -tid -v /home/user/quotesbot:/scrapyrt/project scrapinghub/scrapyrt -i 127.0.0.1
That way it will be accessible only from that machine (e.g. from the frontend application).
Otherwise use firewall to allow communication from your frontend machine only.
My Go application makes TLS connections via tls.Dial() to exchange data.
It works fine when run from the host:
But the outgoing connection doesn't seem to work when the app is run from a Docker container. The app hangs indefinitely.
Note 1: Same behavior with using docker run -p $(docker-machine ip):2500:2500 ...
Note 2: VM doesn't have extra port forwarding settings other than the default settings that came with docker-machine's default VM.
Docker image build with Dockerfile:
FROM golang:latest
RUN mkdir -p "$GOPATH/src/path/to/app"
# Install dependencies
RUN go get github.com/path/to/dep
VOLUME "$GOPATH/src/path/to/app"
EXPOSE 2500
WORKDIR "$GOPATH/src/path/to/app"
CMD ["go", "run", "main.go"]
Host is OS X running docker-machine.
Question
How can I make the TCP outgoing connection to work?
You are either using boot2docker or docker-machine (since you are running docker on OSX). If you are using boot2docker, you have to forward the ports on VirtualBox as well as docker, have a look at this blog post:
https://fogstack.wordpress.com/2014/02/09/docker-on-osx-port-forwarding/
If you are using docker-machine, you have to connect to the docker-machine assigned ip, not localhost, have a look at this post:
https://github.com/docker/machine/issues/710
I see now that you are using docker-machine specifically, so the post about docker-machine should answer your question.
Edit: I misunderstood the question. You are trying to make an outgoing connection on a forwarded port. That is not correct. By default docker can make outgoing connections on any port. The port forwarding is for incoming connections only. Please try again without specifying any ports to forward. My suspicion is that you are trying to make an outgoing connection on the incoming (forwarded) port.
I've just had exactly the same problem. Was unable to connect out at all.
Restarted the container, and suddenly outgoing connections worked fine. It's possible that the container survived an update of docker?
Currently using Docker version 18.09.3, build 774a1f4
Having a problem with deployment of a small Sinatra app that works fine locally, and seems like its running on digital ocean, but can't be hit via the domain name. The following is the message I receive:
This webpage is not available
Error code: ERR_CONNECTION_REFUSED
The following is what's displayed on my droplet using rackup -p 80, which to me indicates it should be able to be hit:
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on localhost:80, CTRL+C to stop
If it makes any difference, I also cannot hit the ip address directly. Anyone encounter similar problems or possibly a solution? The app is on ubuntu uses psql as a database. It would be greatly appreciated. Thanks!
Bind your app on 0.0.0.0 instead of localhost:
ruby your_app.rb -o 0.0.0.0
or
rackup --host 0.0.0.0
In production, you should setup a reverse proxy (eg. using nginx or apache) to bind a domain to your app internal port insteal of opening everything on 0.0.0.0
I have a Pi that runs hostapd and dhcpd on arch linux to create it's own land with the Pi's (routers) IP being 10.0.0.1. This uses the wlan0 interface and it only serves as a standalone router running a web server.
Once I connect to the Pi, I use 10.0.0.1 to display the web pages, but I want to use a hostname such as firepi. I have tried using dnsmasq, but I haven't been successful. Any help would be greatly appreciated especially if you can give me some detailed examples as I am a novice.
The purpose of this system is that I have created a web app that you can use to ignite fireworks over WiFi at a safe distance. I would just like the convenience of using a hostname instead of the IP address.
I must add that I will more than likely be using an iPhone to connect to the server, should this affect anything.
Not too sure how or why but this is what I did and it is successfully working now, so this is just for future users who may need a similar setup to mine.
First I installed hostapd and dhcpd and made sure they were working. Next I changed '/etc/hostname' to firepi and the '/etc/hosts' and added '10.0.0.1 firepi'. Then I installed dnsmasq, and set the interface to wlan0, and finally added '10.0.0.1 firepi' to '/etc/resolv.conf'.
After a full reboot, I joined the network on my iPhone, navigated to firepi and sure enough, it worked!
Thanks to the other users for their advice and tips.
You can use avahi on Arch as well to resolve your hostname:
sudo pacman -S avahi nss-mdns
Start the avahi daemon:
sudo systemctl enable avahi-daemon.service
sudo systemctl start avahi-daemon.service
Edit /etc/nsswitch.conf
sudo vim /etc/nsswitch.conf
Change the line:
hosts: files myhostname dns
to
hosts: files myhostname mdns_minimal [NOTFOUND=return] dns
Reboot
Note: don't forget to add .local to your hostname.
See also:
http://blog.pixxis.be/post/77285636682/resolve-hostname-with-arch-linux-on-a-raspberry-pi
If you just want to be able to use "firepi" as hostname to connect to it, you can simply add it to your /etc/hosts file using the syntax "IP host".
To make it as easy as possible, run this command as root:
echo "10.0.0.1 firepi" >> /etc/hosts
That'll do the trick.
Can you try avahi ?
sudo apt-get install avahi-daemon and
sudo apt-get install avahi-browse
I've successfully used that on Raspian. Unless you change the hostname using
sudo raspi-config you will access via raspberrypi.local
Note that if you plan to access the RPi from Windows you will need to install Bonjour Service first(if you have iTunes intalled, you might have those, run services.msc and check if the Bonjour Service is started)
Another note: On a friend's iphone I've installed a generic vnc client and had x11vnc running on the RPi and succesfully managed to connect to the RPi (since avahi-daemon was installed)
Usage: [options]
Options:
--help, -h Show this help message and exit.
--server=SERVER The server to use to determine the latest
-s SERVER SDK version.
--address=ADDRESS The address of the interface on the local machine
-a ADDRESS to bind to (or 0.0.0.0 for all interfaces).
--port=PORT The port number to bind to on the local machine.
-p PORT
--sdk_root=DIR Overrides where the SDK is located.
--disable_update_check Disable the check for newer SDK versions.
--generated_dir=DIR Set the directory where generated files are created.
--jvm_flag=FLAG Pass FLAG as a JVM argument. May be repeated to
supply multiple flags.
I had come across similar problem while working with Google App Engine for Python-loalhost was not getting its connection established.
$fuser -k 8080/tcp
Try this in terminal/command prompt and restart localhost.
It worked for me. Hope it works for you also. Good luck!