Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » LSP4J : Language Server method call never ends
LSP4J : Language Server method call never ends [message #1851859] Wed, 20 April 2022 12:20 Go to next message
Eclipse UserFriend
I have created a Java-based LSP client, but none of the method calls are completed & it waits indefinitely.

Socket socket = new Socket("localhost", 6008);
Launcher<LanguageServer> createClientLauncher = LSPLauncher.createClientLauncher (languageClient,
                socket.getInputStream(), socket.getOutputStream());
LanguageServer server = createClientLauncher.getRemoteProxy();

createClientLauncher.startListening();
InitializeResult result = server.initialize(new InitializeParams()).get();

System.out.println("end");

initialize method never returns. The Language Server is working fine when tested with the VSCode instance.

Seems like requests are not reaching the server as nothing is printed in trace logs of the server.

Server Code -

Function<MessageConsumer, MessageConsumer> wrapper = consumer -> {
			MessageConsumer result = consumer;
			return result;
		};
		Launcher<LanguageClient> launcher = createSocketLauncher(languageServer, LanguageClient.class, new InetSocketAddress("localhost", 6008), Executors.newCachedThreadPool(), wrapper);
		languageServer.connect(launcher.getRemoteProxy());
		Future<?> future = launcher.startListening();
		while (!future.isDone()) {
			Thread.sleep(10_000l);
		}


What could be the issue here?
Re: LSP4J : Language Server method call never ends [message #1851868 is a reply to message #1851859] Wed, 20 April 2022 16:15 Go to previous message
Eclipse UserFriend
cannot reproduce this with the snippet you share.
do you mean that the main method does not stop?
you dont call System.exit(0); at end
Did you debug if the startListening in the client blocks
Are you sure you create the client socket connection correct ?
Does anything at the server arrive using debugger

I also wonder if you should use AsynchronousSocketChannel
As others do

Maybe you can also check how lsp4e uses
https://github.com/eclipse/lsp4e/blob/607e86e697e49e4f1cb1969ecdf9009cbfa47df4/org.eclipse.lsp4e/src/org/eclipse/lsp4e/server/ProcessOverSocketStreamConnectionProvider.java

you can also check out
https://github.com/TypeFox/lsp4j-chat-app/blob/master/src/main/java/io/typefox/lsp4j/chat/shared/SocketLauncher.java
https://github.com/TypeFox/lsp4j-chat-app/blob/master/src/main/java/io/typefox/lsp4j/chat/client/ChatClientLauncher.java

[Updated on: Wed, 20 April 2022 18:52] by Moderator

Report message to a moderator

Previous Topic:Packages does not exist from Xtext Maven Example
Next Topic:Get already build xtext resource in languageServer
Goto Forum:
  


Current Time: Fri Feb 14 06:05:23 GMT 2025

Powered by FUDForum. Page generated in 0.02393 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top