-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"No connection to Gradle server" in versions 2.6+ #397
Comments
Odd. Can you send me a screenshot of the output of the "Gradle Tasks Server" task in the terminal panel? Can you also confirm if the extension is actually broken for you, or if you're just seeing that message? |
Same here. I’m on Windows 10 and the extension sometimes manage or doesn’t manage to connect to the Gradle tasks server. Whenever it fails to connect, I press on Restart Server and the terminal window pops up only to say that the server has been listened on certain port, but in the end, the Gradle Tasks explorer pane never shows up. |
@h0use thanks for sending these. @vinzlee97 in your case can you also please add any more info, like a screenshot of the output for "Gradle Tasks". Do you get the same "failed to connect" error? Sadly I can't replicate this problem on neither MacOS Catalina nor Windows 10. Seems like a network thing, do you have any local firewalls or proxing enabled for localhost? |
In my case, as I said earlier, the extension sometimes connects successfully to the Gradle Tasks server, and sometimes it doesn't. Here is the failure case screencast: And here's the successful case screencast for the same project: I think it's not the network issue, but if that's the case, can you please tell me the debugging steps? Sorry for the laggy footage, and thanks. |
@vinzlee97 thanks for this. can you try disabling all extensions, then only enable the Gradle Tasks extension, and see if this issue still occurs? You can disable all extensions with the command palette: Can you also send a list of your installed extensions? You can do this with the vscode command line executable:
Also, when the issue occurs, can you try run "Refresh Gradle Tasks" from the command palette and see if that loads the treeview? (although i don't think this will help, but give it a try) |
@vinzlee97 can you also let me know what that green icon on the left of the statusbar is? Are you developing on remotely WSL? Can you let me know any other "non-standard" things you are doing? I'll need to replicate your setup to replicate the bug. If you can give me a good description of your exact setup, then I might be able to replicate. Thanks. |
@h0use It's also appears you're using the remote development feature. Can you also describe your exact setup to help me replicate your scenario. |
Ok I have a theory for this. It seems like it's a race condition due to the time it takes to bootstrap the Java Server process and when the client tries to connect. Series of events:
I was able to replicate this once, when my machine was under heavy load, and with the manual retries disabled, which supports this theory. I think i'm using the wrong vscode API here: I need to be using onDidStartTaskProcess instead. I was using the This is the smelly code to handle client retries: I was always suspicious of why i needed to do this, as the grpc client should be retrying itself. This code is fishy and again supports my theory above. It's a patch over a deeper problem. I believe I've fixed the deeper problem with how i construct the server task. So in simple terms, the fix to only tell the client to connect once the underlying server process has been successfully bootstrapped. I will try get a potential fix out for this today. |
Yeah, it has to do with Java Extension Pack by Microsoft (in my case). So I reopened the same project 10 times for each case of extension disabling scenario, and here are the results: It turned out when I disabled all extensions except Gradle Extension Pack, everything worked fine (10/10 successful connection attempts). The next experiment I tried was to disable all extensions except Gradle Extension Pack and Java Extension Pack, and there was 2 failed attempts at the first and second try, then it connected successfully in the next attempts (8/10 successful connection attempts). And finally, I tried to enable all extensions except Java Extension Pack, which surprised me that all attempts resulted in successful connection (10/10 successful connection attempts). Here is my list of extensions: aaron-bond.better-comments |
I know the Java language server is quite heavy and perhaps it's just a machine load issue. (In that it takes a while to start 2 different Java servers.) I've made a couple changes that can help with this issue. Can you test this fix using Gradle Tasks v3.0.4? Can you test with all extensions enabled? Many thanks. |
Arg. I just spotted this too. Sorry. I assume you're using Git Bash on windows? I'll get a fix out asap. Refs #420 |
Yeah, it's Git Bash. |
Can you try with version 3.0.5? |
Thanks for the screencasts, they're super useful. The root cause is still a race condition. I need to find a way to only let the client connect to server once the gRPC server has started. We can see the problem in your first screencast:
The correct order events should be:
This issue only occurs on slowish machines, where it takes a while for the gRPC server to start. The documentation for the Java gRPC server also states I should only connect once it's started: I had incorrectly assumed the gRPC client would keep retrying to connect, and connect when the server starts, but it seems it needs the server to be started first. Now I better understand this issues, I can try find a fix. Thanks for your help and patience! |
You’re welcome. I’m glad they’re useful. And thanks for the great extension! I look forward for the fix to the issue. |
I've made a change that seems to resolve this issue. The extension will now do the following:
The extension will keep trying to connect to the gRPC socket for a maximum of 2 minutes, after-which it will bail out with an error. I think 2 minutes is more than enough time, even on very slow machines. With this approach, I'm no longer able to replicate the issue, and tests are passing consistently in CI. So this change looks good. Can you test with version 3.0.6? |
I tested in a separate project with all extensions enabled 10 times. All attempted connections were successful. 👍 |
Great news, thanks @vinzlee97! @h0use can you confirm the latest version fixes things for you? |
Actually, today I opened the same separate project in VSCode after turning on my machine. The "No connection to Gradle server" popup message appeared again at some point. It seemed because of the first open workload that made it happen, but after I reopened VSCode, the connection remained successful. I guess in this case, it's my slowish machine which is the cause then. |
Ok, I will add more logging around why the client is struggling to connect, increase the connect deadline, and add a mechanism for you to manually recover in this scenario. |
I'll test it in the next machine boot. |
So I couldn't replicate the failure case after I rebooted my machine. In my recent reboots, the connection was successful though. Here's the output: And here's the terminal contents:
I will try to reconnect after I encounter the failure case, and I'll report it here. For now, everything seems fine if those exceptions don't affect the connection and thanks for the fix anyways. |
I’ve been AFK for a couple of days but I’ll give it a go this weekend when
I’m back to work!
On 21 May 2020, at 19:22, Richard Willis <[email protected]> wrote:
Great news, thanks @vinzlee97 <https://github.com/vinzlee97>!
@h0use <https://github.com/h0use> can you confirm the latest version fixes
things for you?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#397 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJTYJ24RY6LEZMRZUL6T7TRSVWPBANCNFSM4NBS7PYQ>
.
|
@vinzlee97 Cool. I'll do a bit of research to better understand the cause of those exceptions. Is the speed in your GIF real-time or slowed down? @h0use cool thanks! No rush, whenever you get a chance. It's be useful to know if things are fixed for you. |
@badsyntax since i maxed out the GIF quality, the speed itself became a bit of laggy. But, in the last GIF, it's realtime, because the process itself was slow on my machine (I shouldn't have cropped out the Gradle: Connecting indicator 🤦. It spun during the course of the GIF until the process was finished). |
That's fine. Indeed this is quite slow. I'm not sure the slow speed is specific to the extension, it looks like generally your machine is quite slow. I don't think there's much I can do to improve the speed for you sadly. I need to use Java to use the Gradle Tooling API and unfortunately the JVM is a bit slow to start up, but once the the server has run the initial Gradle build it should be fairly quick thereafter even on slow machines. Can you copy/paste the the |
I reopened VSCode after the last GIF recording, but I believe the JVM Args remains the same no matter how many times I reload VSCode. Here you go:
|
After I boot up and open VSCode today, the extension doesn't manage to connect to Gradle server at all (the output panel doesn't show anything, but in the terminal panel, it notified "Server started, listening on XXX"), and strangely, the failure connection message didn't pop up. What I did was to reconnect it manually:
I hope this will become handy to someone. |
@vinzlee97 When you say "the output panel doesn't show anything" do you mean literally nothing is displayed, in that the "Gradle Tasks" output panel is just empty? Sometimes vscode takes a little while to render the output, but there should be some output displayed in all cases. Next time this happens, can you wait a bit to give vscode some time to render the output. And can you paste a screenshot of the output panel when this happens again? Thanks! |
Yeah, it didn't show anything and I waited for it in case some debugging info appeared, but unfortunately nothing came out. I'm not so sure what caused it though, but I'll try to wait for a bit longer next time (and maybe I'll test by disabling some extensions beforehand). Anyways, what did you notice in the JVM Args? @badsyntax |
I'm seeing issues with the client connecting in v3.0.7. Other system info:
The server begins listening, and it's as if the client never attempts to connect. I can connect to the server by using telnet by targeting either 127.0.0.1 or my machine's ethernet IP. Server:
Client (Gradle Tasks):
I've tried various combinations of closing the server and attempting to re-connect / restart the server. I can't see any dropped packets in Windows Firewall logs. How does the client determine which server host/port to connect to? My suspicion is that my corporate network setup is at fault. |
The client attempts to connect using If you like you can hack the extension to get the grpc client to use In (warning: it's a big ol file) replace |
Sorry for the delay in getting back to you on this one. I modified the line you suggested and found the following:
I was going to suggest that this could be related to the bind address that the server component is using, but that doesn't seem likely. As mentioned earlier, I have no problem connecting to the server on any of the above three addesses from another process (e.g. telnet). I might raise this with our networking team and see if there are any diagnostics they can perform on my machine to work out what is blocking the connections via the loopback address. |
I've just tried localhost, 127.0.0.1, my local ethernet address and my work VPN address to no avail. I'm guessing it's a problem with the VPN or other network security malarkey they've installed on this Mac. Not sure what to try next. |
@h0use - I installed Wireshark and was able to see where my packets were going on a connection. This helped immensely - perhaps vscode is sending them to a HTTP proxy? @badsyntax - thank you very much for your help. My localhost / 127.0.0.1 connections were being routed to a proxy. I added a NO_PROXY environment variable in Windows and it's now working fine.
I don't know much about gRPC (it appears you're using that for the client connection), but is it possible to invoke it with no proxy for your extension? It seems unlikely that a proxy would be needed for inter-process communication on the same machine. I'd love to contribute code here, but I'm not an expert on typescript or gRPC. My guess would be that on line ~90 of
to
|
@badsyntax - I've actually given this a try by hacking at the minified file you pointed me towards, but it didn't work (despite being documented that it should work). Is vscode intercepting http calls? 😕(That may be a stupid question, but I'm not super familiar with the Node / Electron / TypeScript stack.) |
@studro thanks for this investigation, this is super useful. I'm using the grpc-js package, which is a fairly new package and only recently came out of beta. I have previously discovered some issues with it, so there's a chance it's just not honouring that setting. I will spend a bit of time understanding the grpc proxying and try determine if it's an issue with the package and get back to you. |
@badsyntax - No problem at all. I also found this comment regarding vscode patching the http and https modules in Node. That might mean that nothing can be done anyway and you will need to rely on users having Let me know if you need any help testing any fixes or digging up information from my config. |
if you have a system level proxy then grpc will attempt to use that proxy. (you can see grpc attempting to use system level proxy here). this is also why setting i've been able to replicate this issue on my machine: i set a bogus http proxy env var: so as you discovered we just need to somehow tell the grpc client to not use the system proxy. i don't want to set env vars at runtime and i don't want to rely on the user setting an env var. it would be ideal if we could just disable the proxying in the grpc client with @h0use does this fix work for you? try setting |
After speaking with the authors of grpc-js, I'm going to add the client option to grpc-js to disable http proxying in the client. PR here: grpc/grpc-node#1454 Interestingly, I found a fix waiting to be released that will fix the race condition issue mentioned further up in this thread, see grpc/grpc-node#1446 Once that fix is released I'll be able to remove my workaround code. |
Setting no_grpc_proxy fixed it!! Awesome stuff. Thanks so much. Happy to help test any more permanent fixes for this when they're ready. |
Awesome! Thanks to @studro for figuring out it was a proxy issue 👍 Now I'm just waiting on @grpc/[email protected] to be released before I can add a permanent fix. |
|
thanks @murgatroid99! i will try get the permanent fix out today. |
@h0use @studro i've now released 3.0.8 with the permanent proxy fix. You can remove the I believe the original issue is now fixed so i'm gonna close this issue, please re-open if it's not fixed for you. @vinzlee97 as your issue isn't related to the issue OP mentioned, please create a new issue if you're still having problems. thanks all. |
Awesome stuff! Thanks to you and everyone else for figuring it out and fixing it! |
I'm having the same issue of "No connection to Gradle server" in v3.12.5 and adding localhost to no_grpc_proxy resolved the issue. Setup: I am using VS Code Remote-SSH Extension to connect to a virtual machine running Rocky8 with Gradle version 6.8.3. The host OS is Windows 10. |
Since 2.6 (and, I'm guessing, as a result of the gRPC refactor?) my VS Code shows "no connection to Gradle server" whenever it starts, in spite of the log showing "Server started, listening on XXX".
This is on VS Code 1.45.1 on Mac OS Catalina, running Zulu JDK 11.
Thanks so much for your work on this plugin! It's really appreciated :)
The text was updated successfully, but these errors were encountered: