PhpStorm xdebug on WSL2 - Waiting for incoming connection - docker

I am running Windows with WSL2 and Ubuntu 18.04 in there. The webserver is running in Docker Desktop. Xdebug is set up and PhpStorm configured. But I always get "Waiting for incoming connection with ide key 'PHPSTORM'". I have also installed Xdebug toolbar in the browser and set the ide key there.
In the run configuration I set the server to sw6.dev.localhost. That is the URL in the browser. But I also tried 127.0.0.1 and localhost. Always the same result. Do you have an idea what is going wrong?
I have read that the docker container always got a new IP. Could that be the problem?
In the docker file I have set: xdebug.remote_host = host.docker.internal
In the xdebug.log I got:
[27] I: Checking remote connect back address.
[27] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[27] I: Remote address found, connecting to 172.26.0.1:9000.
[27] W: Creating socket for '172.26.0.1:9000', poll success, but error: Operation in progress (29).
[27] E: Could not connect to client. :-(
My xdebug.ini looks like this:
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_log=/tmp/xdebug.log
xdebug.idekey=PHPSTORM
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.profiler_output_name = "cachegrind.out.%R.%t"
xdebug.auto_trace=0
xdebug.trace_enable_trigger=1
xdebug.trace_output_dir="/var/www/html/traces"
xdebug.trace_output_name="trace.%R.%t"
xdebug.show_mem_delta=1
I am not sure about the IP. Should that be the IP of the docker container with nginx?
I have set -Djava.net.preferIPv4Stack=true in PhpStorm's vmoptions.
Any help would be greatly appreciated.

Related

MQTT connection refused when trying to connect from remote machine

I am trying to connect to a mosquitto broker, across linux clients. I can get everything working from the local machine, but when trying to connect from another machine I get the error ConnectionRefusedError: [Error 111] Connection refused.
Here is the process:
On the local machine, I install mostquitto, stop the service and start a live instance:
#Terminal 1
sudo service mosquitto stop
mosquitto
I then try and pub and sub, from distinct terminals on that machine:
#Terminal 2
mosquitto_sub -t 'test'
#Terminal 1 shows new connection
#Terminal 3
mosquitto_pub -t 'test' -m 'Hello, world!'
#Terminal 1 shows new connection, and then disconnect.
#Terminal 2 shows 'Hello, world!'
I now try to connect from a remote machine. First I edit the mosquitto config file to allow unauthorized connections:
sudo nano /etc/mosquitto/mosquitto.conf
#Add the following:
listener 1883
allow_anonymous true
protocol mqtt
I note that the mosquitto logs previously showed only local connections allowed, after editing the config file and restarting, the logs no longer show that message.
Then I install paho-mqtt on another machine. I run the following python script:
import paho.mqtt.client as mqtt
client = mqtt.Client('131')
client.connect('192.168.0.146') #The IP of machine 1, running the broker where the code above ran correctly across the terminals
I get the error mentioned above:ConnectionRefusedError: [Error 111] Connection refused. The mosquitto instance on machine 1 shows nothing. Logs show nothing.
I can't work out what is going on. I have read every question on SO that I can find. Nothing goes beyond changing the config file. I have tried running the broker on two machines (laptop and pi). I have tried connecting from multiple different sources: esp32 board, different laptop and pi. Nothing works. I can only assume there is some network-wide problem, but my network isn't isolating devices as I ssh into my pi all the time and have wifi lights and switches running on the LAN.
If anyone can help me troubleshoot I would be very grateful.
Mosquitto will not pick up a default configuration file, you must always pass the configuration file with the -c command line argument or it will fall back to the baked in config (that will only listen on localhost)
The service includes -c /etc/mosquitto/mosquitto.conf to force it to use the config file.

weblogic in docker trying to use the public port in the container when 7101:7001 port mapping is used

I am starting a WebLogic 12.2.1.4 admin server in docker from my docker-compose.yml file.
I use different port mapping, not the default 7001.
My docker port mapping is this: 7101:7001
Everything works fine, except this: I constantly get the following exception when I click on the Deployment menu on the web console:
<Feb 12, 2021 5:11:21,002 PM UTC> <Notice> <JMX> <BEA-149535> <JMX Resiliency Activity Server=All Servers : Resolving connection list DomainRuntimeServiceMBean>
javax.ws.rs.ProcessingException: java.net.ConnectException: Tried all: '1' addresses, but could not connect over HTTP to server: 'localhost', port: '7101'
failed reasons:
[0] address:'localhost/127.0.0.1',port:'7101' : java.net.ConnectException: Connection refused
The WL admin server tries to use the public docker port 7101 in the container but actually, WL is listening on the default 7001 port inside the container. Port 7101 is only used from the host machine, and of course, WL is not listening on port 7101 in the container.
My workaround is the following:
Check the IP address of the admin-server container with docker inspect <container-name>
Open the WL console using the container private IP address, e.g.: http://172.19.0.2:7001/console
In this case, the exception does not appear
But if I open the WL console from http://localhost:7101/console which is the mapped port to the host machine by docker, then the exception appears
Maybe this is a WL user interface issue? But I am not sure.
Any idea why this happening?

PyCharm cannot use interpreter in server docker-machine(Channel disconnected before any data was reveived)

I am using MAC OS + PyCharm(for pro) and ubuntu16.04 server.
When I try to connect to the server's docker using local pycharm, I get the following error:
( Cannot connect: java.io.IOException: Channel disconnected before any data was reveived )
( I changed the docker daemon port. )
And, I tried searching for ports, and worked well.
Port Scanning host: 163.---.---.178
Open TCP Port: 7561
Even if I tried changing tcp to https, it gave an error.
How can I fix it?
1.set this item first, then reboot your laptop. Run pycharm as administrator, it works for me.

Docker - Hostname was NOT found in DNS cache

I am using a Dockerfile to hit our corporate Nexus (npm) server for 'npm install' commands. I am seeing:
* Hostname was NOT found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 216.xxx.xxx.xxx...
* connect to 216.xxx.xxx.xxx port 443 failed: Connection refused
* Failed to connect to nexus.<something>.com port 443: Connection refused
* Closing connection 0
curl: (7) Failed to connect to nexus.<something>.com port 443: Connection refused
I can resolve www.google.com. I can hit and and use our corporate NPM registery from my local box. It appears that only our internal dns names are the problem and only when attempting to access them from inside a docker container. I've googled and not been able to determine the changes I need to make to fix this problem.
Dockerfile (I've trimmed the irrelevant commands):
FROM node:6.3
RUN curl -k -v https://www.google.com
RUN curl -k -vv https://nexus.<something>.com/repository/npm-all/
The curl to google.com succeeds. The curl to our internal repo fails.
I am starting it with the command:
docker build .
Contents of /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
I am running Ubuntu 15.10.
Solution
#BMitch is correct. Modify the contents of /etc/resolv.conf by adding dns server addresses associated with your corporate network. In the case of Ubuntu 15+ (i am running gnome3) your config file will be overwritten by the Network Manager so it cannot be hand edited. Make the changes via the Network Manager gui. Open Network Settings, select the DNS tab and add servers.
The local dns address is the issue you're facing. The container can't connect to your localhost ip from inside the container. The solution is to pass an ip address of the DNS server in your docker run or update your /etc/resolv.conf to point to a non-loopback ip address.
From Docker's DNS documentation:
Filtering is necessary because all localhost addresses on the host are
unreachable from the container’s network. After this filtering, if
there are no more nameserver entries left in the container’s
/etc/resolv.conf file, the daemon adds public Google DNS nameservers
(8.8.8.8 and 8.8.4.4) to the container’s DNS configuration. If IPv6 is
enabled on the daemon, the public IPv6 Google DNS nameservers will
also be added (2001:4860:4860::8888 and 2001:4860:4860::8844).
Note: If you need access to a host’s localhost resolver, you must modify your DNS service on the host to listen on a non-localhost
address that is reachable from within the container.

Neo4j remote shell through vagrant issue

I'm running a Neo4j instance inside my Vagrant machine. I put these lines into neo4j.properties to start the server with the remote shell
remote_shell_enabled=true
remote_shell_host=0.0.0.0
remote_shell_port=1337
I start neo4j server with the command bin/neo4j start
After that, I use neo4j shell inside vagrant to connect to the remote shell and it works fine.
I forward the port 1337 to the host machine with this in the Vagrantfile
config.vm.network :forwarded_port, guest: 1337, host: 9255
And then on my host machine (MacOS), I use the neo4j shell to connect to that server but I fail
$ bin/neo4j-shell -port 9255 -v
Unable to find any JVMs matching version "1.7".
ERROR (-v for expanded information):
Connection refused
java.rmi.ConnectException: Connection refused to host: 10.0.2.15; nested exception is:
java.net.ConnectException: Operation timed out
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
at com.sun.proxy.$Proxy1.welcome(Unknown Source)
at org.neo4j.shell.impl.AbstractClient.sayHi(AbstractClient.java:254)
at org.neo4j.shell.impl.RemoteClient.findRemoteServer(RemoteClient.java:70)
at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:62)
at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:45)
at org.neo4j.shell.ShellLobby.newClient(ShellLobby.java:178)
at org.neo4j.shell.StartClient.startRemote(StartClient.java:302)
at org.neo4j.shell.StartClient.start(StartClient.java:179)
at org.neo4j.shell.StartClient.main(StartClient.java:124)
Caused by: java.net.ConnectException: Operation timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 14 more
The vagrant machine has no firewall and I'm still able to connect to the web interface
UPDATE
Holy ###**(* I got it working after 6+ hours! With default configuration Neo4j only accepts local connections. I'm not a networking wiz, but apparently neo4j could tell that port forwarded connections are non-local, and refused them. To fix, you need to configure your neo4j.conf file to accept non-local connections
# To accept non-local connections, uncomment this line:
dbms.connectors.default_listen_address=0.0.0.0
# You also need to remove the 'advertised_address' from each connector,
# so that only the port is specified
# i.e. my conf file originally had dbms.connector.bolt.listen_address=localhost:7472
# I changed it to dbms.connector.bolt.listen_address=:7472
# Bolt connector
dbms.connector.bolt.enabled=true
dbms.connector.bolt.listen_address=:7472
# HTTP Connector. There must be exactly one HTTP connector.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474
# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=false
dbms.connector.https.listen_address=:7473
Of course, in addition to all of this you need to have port forwarding properly set up in your vagrantfile. Strangely, I found I needed to make sure I was sharing every port neo4j was broadcasting on (http, https, bolt) or else there were some intermittent connection issues with the web console. This all being said, I can now properly connect via neo4j-shell, cypher-shell, and the web console--all from my host machine.
Original
I'm running into a similar problem. In your case, the output error includes Unable to find any JVMs matching version "1.7". The bin/neo4j-shell file is written in Java, I believe (or perhaps the shell it starts relies on Java). The host machine needs to have the java development kit (JDK) installed to run that command. Try installing the JDK and running it again.
This all being said, I DO have the JDK installed on my machine (now "1.8") and I'm running into a similar problem when I try and run bin/cypher-shell (which has replaced bin/neo4j-shell) from my host machine (a mac): Unable to connect to localhost:7687, ensure the database is running and that there is a working network connection to it. When I try and connect from within vagrant, I do not run into any errors. My vagrantfile contains config.vm.network "forwarded_port", guest: 7687, host: 7687, host_ip: "127.0.0.1".
I'll also note that, while I can connect to the neo4j web interface within vagrant, I cannot connect to the web interface on my host machine (i.e. port forwarding doesn't seem to be working for anything neo4j related). I can connect to a rails app running within the same vagrant box from my host machine just fine, however. While I haven't tried it, I imagine I can indirectly access the neo4j database through my Rails app (since my Rails app is port forwarding correctly).
Still I cannot fix this problem, but I find another work around so I will post it here. We can use an ssh tunnel to pretend that we are connecting to localhost from that server. Use ssh to execute the command directly from the remote host
ssh user#host /path/to/neo4j-shell
or if you are using vagrant
vagrant ssh -c '/path/to/neo4j-shell'

Resources