randy3k / RemoteSubl

Use rmate with Sublime Text, an improved fork of rsub.
327 stars 20 forks source link

OSError: [WinError 10013] on Windows 10 #29

Open ghost opened 3 years ago

ghost commented 3 years ago

Hello :)

Is it possible to fix this error somehow?

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text\Lib\python33\sublime_plugin.py", line 528, in on_api_ready
    plc()
  File "C:\Users\User\AppData\Roaming\Sublime Text\Installed Packages\RemoteSubl.sublime-package\remote_subl.py", line 331, in plugin_loaded
    server = TCPServer((host, port), ConnectionHandler)
  File "./python3.3/socketserver.py", line 430, in __init__
  File "./python3.3/socketserver.py", line 441, in server_bind
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

Thanks, Ihor

ScribblerCoder commented 1 year ago

Hey, I faced the same issue today. Suddenly the plugin was no longer working and I couldn't edit any files over ssh. I started debugging:

TDLR: I hate windows

https://stackoverflow.com/questions/10461257/an-attempt-was-made-to-access-a-socket-in-a-way-forbidden-by-its-access-permissi

Long story short, run this in cmd as administrator

net stop hns
net start hns


Details:

I ran my usual ssh command but with -v option to check if the port forwarding was successful

.........SNIP.........
debug1: remote forward success for: listen 52698, connect 127.0.0.1:52698
debug1: All remote forwarding requests processed
.........SNIP.........

I checked that the server is listening on port 52698:

user@53rv3r:~$ sudo lsof -i TCP:52698
[sudo] password for silver:
COMMAND    PID   USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
sshd    655793 user   10u  IPv6 248089764      0t0  TCP ip6-localhost:52698 (LISTEN)
sshd    655793 user   11u  IPv4 248089765      0t0  TCP localhost:52698 (LISTEN)

then I checked if the client (Sublime Text) is listening on 52698 and it wasn't 😭

PS C:\Users\user> netstat -on | Select-String 52698  
PS C:\Users\user>

reinstalling ssh client/server on windows didn't help so I started debugging the plugin python script and ran the following simple code and it caused the same error mentioned in this issue

from threading import Thread
import socketserver

class ConnectionHandler(socketserver.BaseRequestHandler):           
    def handle(self):
        self.data = self.request.recv(1024).strip()
        print("{} wrote:".format(self.client_address[0]))
        r = ConnectionHandler(self.data, False)

class TCPServer(socketserver.ThreadingTCPServer):
    allow_reuse_address = True

server = TCPServer(("localhost", 52698), ConnectionHandler)
Thread(target=server.serve_forever, args=[]).start()

The issue was from Host Network Service from windows which didn't allow RemoteSubl to listen on 52698 (I hate windows)

Check out https://stackoverflow.com/questions/10461257/an-attempt-was-made-to-access-a-socket-in-a-way-forbidden-by-its-access-permissi

Run these commands on cmd as administrator and it should solve the issue

net stop hns
net start hns

@randy3k Maybe this workaround should be added in troubleshooting section