Using WSL2 python console when connected to a VPN Follow
I have defined a WSL2 python3 interpreter to run with PyCharm. I have been able to connect the WSL2 terminal as well as the python interpreter and they work just fine with PyCharm. However, when I connect to my company VPN I can not open the python terminal.
Some of the configurations I have performed on WSL2 are as following:
- I added my company DNS IP to the /etc/resolv.conf file as "nameserver XX.XX.XX.XX" as well as a default one. This will allow me to use the intended DNS to route the traffic depending on my connection.
- Also, each time I connect to my VPN I need to update the Interface Metric. Othewise I wouldn't have internet connection when using the VPN. For that, I run the following command on a PowerShell:
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
With this setup, I have internet connection on my WSL2 even when I am connected to the VPN or directly on the company intranet.
However, if I go to PyCharm and try to open a python console I receive an error message saying "Couldn't connect to console process. Process finished with exit code -1". This is weird as I can access it without any problem if I just use my own internet connection instead of the VPN. I have tried to open the terminal inside PyCharm (which is my WSL2 terminal) when connected to the VPN and everything works fine, I have internet connection.
This is what I find in the idea.log file after receiving the error message.
2022-05-23 17:18:14,357 [2281001] INFO - #c.j.p.s.f.PySciEnvironmentProvider - Plots on port: 63342
2022-05-23 17:18:18,617 [2285261] WARN - #c.i.o.d.Logger - io.netty.channel.AbstractChannel$AnnotatedSocketException: Permission denied: no further information: /172.29.89.68:45185
org.apache.thrift.transport.TTransportException: io.netty.channel.AbstractChannel$AnnotatedSocketException: Permission denied: no further information: /172.29.89.68:45185
at com.jetbrains.python.console.transport.client.TNettyClientTransport.open(TNettyClientTransport.kt:115)
at com.jetbrains.python.console.PydevConsoleCommunicationClient$connect$1.run(PydevConsoleCommunicationClient.kt:69)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:295)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: io.netty.channel.AbstractChannel$AnnotatedSocketException: Permission denied: no further information: /172.29.89.68:45185
Caused by: java.net.SocketException: Permission denied: no further information
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:710)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Please sign in to leave a comment.