I planed to deploy OpenSearch with Python FastAPI + Uvicorn.
I upload FastAPI python script and start server with uvicorn command, only internal connection work and external not.
This is my env and and options.
CentOS7
python 3.9
fastapi 0.79.1
uvicorn 0.16.0
CORS setting...
origins = [
'*'
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=False,
allow_methods=["POST"],
allow_headers=["*"]
)
uvicorn
host: 0.0.0.0
port: 5650
port state
5650 port's state is LISTEN when I check netstat -tulnp
and also firewalld is disabled.
External Connection is possible with OpenSearch Node and Dashboards (port 9200, 5601)
Only FastAPI + Uvicorn couldn't...
Sorry for my short english...
I need some help...
Related
I'm trying to use a raspberry pi 4 as a simple peerjs server.
Here's my command that works well in local: peerjs --port 9000 --key peerjs --path /videocallapp
I opened my router like this
But I can't connect to it using my simple peerjs javascript client set up like that : host: '192.***.*.**', port: 9000, path: '/videocallapp'
Host here is the ip of raspberry
Can you please help me?
What I precisly don't know is: does the host ip written in the client is wrong or is it the port that is wrongly set up
I solved it : here's the configuration
server: peerjs --port 9000 --key peerjs --path /videocallapp
router: Web Server (HTTP) internal:9000 external:80 protocol:TCP equipment: raspberrypi
client: ip:your public Ip! (https://canyouseeme.org/) port:80
I'm doing development with VSCode Remote SSH, where CentOS 7 is running.
I use BrowserSync to proxy remote URL, it was usually running on localhost:3000 and localhost:3001 (this is the default)
but some time ago after I played a little with VSCode extensions for this purpose I noticed, that VS Code Remote started to auto-forward ports 3000 and 3001 to some random ports like 581116 etc.
If I try to change 'Local address' on "ports" tab to 3000, I get error "the local port 3000 is not available'.
If I set up Browsersync to use ports 3002 and 3003 for example, VS Code forwards them as 3002 -> 3002, 3003 -> 3003, that is expected, but not with 3000 / 3001 anymore. I suspected that some unfinished process occupied this port, but I cannot detect any connected processes with sudo lsof -i -P -n and any other command I tried.
I tried also npx kill-port 3000, but this didn't help either.
What is happening and how can I claim my localhost:3000 back?
I have two computers within the same network. One of them is a server, which serves a publicly accessible website; the other one is for my daily use.
Both computers are using Microsoft technologies. (Windows Server 2019/Windows 10)
I have a MongoDB instance running on the server, and I want to connect it using my daily PC.
However, if I try to connect to the MongoDB instance (mongodb://192.168.50.33:27017, 192.168.50.33 is the local IP address of the server PC, 27017 is the port for the instance), it always timeout using
Google Chrome: If the connection works, I should see a message saying It looks like you are trying to access MongoDB over HTTP on the native driver port..
MongoDB Compass: If the connection works, I should be able to see the content inside the database.
I have tried/setup the following:
Setup an inbound firewall rule with the following properties:
Allow connections
Protocol: TCP
Ports:
Local: All ports
Remote: 27017
Scope: Any Local/Remote IP addresses
Apply to Domain, Private, Public
Checked the firewall log. Saw that the connection from my daily PC is allowed through the firewall.
Set up a port forwarding on the router (ASUS RT-AC58U) which connects to both of my computers with the following properties:
Port Range: 27017
Local Port: 27017
Local IP: 192.168.50.33
Set the net.bindIp of the configuration of the MongoDB instance to be 0.0.0.0
Any ideas?
bindIp value in mongodb config file should have the address of your server/lan as well to access.
net.bindIp=0.0.0.0,192.168.50.33
for more info you can visit the below link:
https://mkyong.com/mongodb/mongodb-allow-remote-access/
Download the app from the below link and also check if you can ping to mongodb server from 27017:
https://www.elifulkerson.com/projects/tcping.php
tcping.exe 192.168.50.33 27017
And use mongo client to check if you can connect, below is the command:
mongo --host 192.168.50.33 --port 27017
If this also does not help try starting the mongodb using the below commands and then try to access them:
mongod --bind_ip=192.168.50.33 --port=27017
mongod --bind_ip_all --port=27017 (works only if mongodb is 3.6 or greater)
Let me know the what happens.
I am completely new to docker. I followed this instruction to install mongodb chart and docker.
When I connect to 172.17.0.1, it said
Unable to connect to MongoDB using the specified URI.
The following error was returned while attempting to connect:
MongoNetworkError: failed to connect to server [172.17.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 172.17.0.1:27017]
The result from pinging the specified server "172.17.0.1" from within the container is:
PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data.
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.050 ms
--- 172.17.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.050/0.050/0.050/0.000 ms
The mongodb is running on local machine. I think it is not running in the container (not sure) because I installed mongodb in my machine before I install docker.
I have also checked the setting by using docker network inspect bridge
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
This is the yml file:
version: "3.3"
services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
ports:
# host:container port mapping. If you want MongoDB Charts to be
# reachable on a different port on the docker host, change this
# to <port>:80, e.g. 8888:80.
- 80:80
- 443:443
volumes:
- keys:/mongodb-charts/volumes/keys
- logs:/mongodb-charts/volumes/logs
- db-certs:/mongodb-charts/volumes/db-certs
- web-certs:/mongodb-charts/volumes/web-certs
environment:
# The presence of following 2 environment variables will enable HTTPS on Charts server.
# All HTTP requests will be redirected to HTTPS as well.
# To enable HTTPS, upload your certificate and key file to the web-certs volume,
# uncomment the following lines and replace with the names of your certificate and key file.
# CHARTS_HTTPS_CERTIFICATE_FILE: charts-https.crt
# CHARTS_HTTPS_CERTIFICATE_KEY_FILE: charts-https.key
# This environment variable controls the built-in support widget and
# metrics collection in MongoDB Charts. To disable both, set the value
# to "off". The default is "on".
CHARTS_SUPPORT_WIDGET_AND_METRICS: "on"
# Directory where you can upload SSL certificates (.pem format) which
# should be considered trusted self-signed or root certificates when
# Charts is accessing MongoDB servers with ?ssl=true
SSL_CERT_DIR: /mongodb-charts/volumes/db-certs
networks:
- backend
secrets:
- charts-mongodb-uri
networks:
backend:
volumes:
keys:
logs:
db-certs:
web-certs:
secrets:
charts-mongodb-uri:
external: true
How can I connect to the mongodb?
By default mongodb is configured to only accept results from localhost 127.0.0.1 and when charts image connects to it via docker it is seen as an external connection coming from docker0 and it is hence rejected by mongod [MongoNetworkError: connect ECONNREFUSED 172.17.0.1:27017]
To fix this, edit the mongo config sudo vim /etc/mongod.conf and add your docker0 ip to the bindIp config the line with bindIp: 127.0.0.1 should be changed to bindIp: 127.0.0.1,172.17.0.1 for default docker installations.
This may be an old question but I think it could be a common issue, I had to struggle with this for a while before actually reading the error message more thoroughly and realising it really a simple issue.
Another issue is that the upon first install you can connect to mongo without a username or password, so those two should be deleted from the uri if you had not configured security, making it mongodb://172.17.0.1:27017.
Assuming you know how to use echo "mongodb://<username>:<password>#myhost.com/" | docker secret create charts-mongodb-uri - to create the connection the url.
The problem is actually how to connect from a docker container to a outside service running on the host machine. You can use some help from plenty of questions like From inside of a Docker container, how do I connect to the localhost of the machine?
Basically, if you are using docker for mac or windows, use something like echo "mongodb://host.docker.internal" | docker secret create charts-mongodb-uri -, for linux see https://docs.mongodb.com/charts/master/installation/ section RUNNING METADATA DATABASE ON LOCALHOST for the doc, or just use host mode (remove ports section)
version: "3.3"
services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
network_mode: "host"
...
I used vagrant ubuntu server(16.04): 127.0.0.1, and port is 2222 for developing web application, the test code (app.py)as following:
import logging; logging.basicConfig(level=logging.INFO)
import asyncio, os, json, time
from datetime import datetime
from aiohttp import web
def index(request):
return web.Response(body=b'<h1>Awesome</h1>')
#asyncio.coroutine
def init(loop):
app = web.Application(loop=loop)
app.router.add_route('GET', '/', index)
srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 2222)
logging.info('server started at http://127.0.0.1:9000...')
return srv
loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()
After I run the code in the ubuntu server as following:
and then I want to test the app in browser, but there is no response! and error:
The issue is that the server is listening on IP 127.0.0.1 on the VM so you will not be able to access from your host.
If you want to access it from your host browser, you'd need to run your server on a dedicated IP or on the 0.0.0.0 IP so change to
srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 9000)
then make sure to forward this port from your Vagrantfile:
config.vm.network "forwarded_port", guest: 9000, host: 9000
and you'll be able to access it on http://localhost:9000 from your host
the default 2222 port is from forwarded 22 from host machine ssh.. are you sure you port_forwarded setting in your Vagrantfile is correct..?also check in you host machine if the port that you want to open is really open using sudo netstat -ntlp usually vagrant port will have a PID of VBOXHeadless