XFY9326 / Zotero-WSL-ProxyServer

Make Zotero on Windows hosts accessible in WSL
16 stars 1 forks source link

Connection refused on WSL2 with Windows 11 (Zotero 6) #2

Closed HackXIt closed 9 months ago

HackXIt commented 9 months ago

Greetings,

I have set up my project as you have described, including the modifications to settings.json: (allthough it is inside my .code-workspace in my case)

{
        "zotero.serverUrl": "http://172.20.128.1:23119/",
        "zotero-citation-picker.port": "http://172.20.128.1:23119/better-bibtex/cayw?format=pandoc",
}

I started the application on my Windows 11 machine, and it asked for firewall settings to be added, which I accepted. Furthermore, I also confirmed that the firewall settings are inside Firewall rules and everything seems fine there.

All required extensions are installed inside VS Code for WSL2 as well. From a terminal inside WSL2, I can successfully call curl -I http://172.20.128.1:23119/connector/ping:

HTTP/1.0 200 OK
Server: Zotero-WSL-ProxyServer/0.1.0.3 Python/3.10.11
Date: Wed, 24 Jan 2024 18:22:43 GMT
X-Zotero-Version: 6.0.30
X-Zotero-Connector-API-Version: 2
Content-Length: 0

I am running WSL2 on Debian 12 by the way.

Anytime I attempt to use one of the extensions, be it zotero or zotero-citation-picker, I get a connection refused error or just a could not connect to Zotero message.

Looking at your python code, I also can't see anything wrong, since I doubt it's an issue with the code. The requests themselves never reach the proxy server, since there are no logs of them shown. But there's nothing else I would know to configure inside WSL2 or VS Code. I attempted to forward the port in VS Code, tried different variations of the target host hackxit.local or just 127.0.0.1 (the latter wouldn't work as you've already described), but no difference in the problem.

What could be going wrong here?

I've run out of resources to debug this issue and am dearly seeking help.

XFY9326 commented 9 months ago

Hello, I cannot reproduce this problem using the latest version of Zotero in Ubuntu WSL2 on Win11.

I think since you can access connector/ping, the proxy server is doing its job. The could not connect to Zotero error is more likely to occur when the specified Zotero server URL does not have any services.

So I think it's possible that you didn't set settings.json correctly. It is recommended that you set the Zotero server URL through the settings interface of VSCode in WSL2 to avoid any errors. Please make sure you set the Zotero server URL in WSL2 not WIndows.

If the problem persists, you can set a debug breakpoint in the def _handle_zotero_request function to test whether the proxy server received the request in WSL2. This can provide information for further troubleshooting.

HackXIt commented 9 months ago

It ended up working after some tries, at least for the auto-citation. But I agree with you, I believe it has to do something with my setup and I think my windows dislikes the executable.

I'm going with the script now, since that's reliably working.