-
Notifications
You must be signed in to change notification settings - Fork 328
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
Is socket support works correct? #245
Comments
@aeschli can you please answer. You originally put that in. |
Sorry, I'm not really the node streams expert. So maybe this never worked? |
It looks like ALL LSP implementations based on this package have the same issue! |
I've tried connecting to the example server in the past and also got nowhere. Please see Microsoft/vscode-languageserver-node-example#37.. |
So will there be a fix for this? |
Fixed. Published as 3.5.0-next.1 Please note that socket connections are only supported when both the client and server run on the same machine. |
@AHaberl usually a PR helps as well :-) |
@dbaeumer I don't understand your fix. The code for creating a server socket uses Net's The server will not start because it tries to connect to port 3000 instead of listening on port 3000. |
I have opened #260 with a proposed fix that corrects the original problem that was caused by the pipes reading and writing in the wrong direction. |
@rcjsuen I forgot to add some documentation on how this is supposed to work: To avoid any timing or port issues the pipe and the sockets are owned by the client processes since it is already running. The server process simply connects to the pipe / socket. In node term the VS Code process calls I will update the documentation to make this clear for users that implement a server in a different programming language. |
Thank you for your clarification, @dbaeumer. I see now that the client is supposed to listen for connections on the specified port and the language server should be started up to connect to the specified port. I hope the following code will be of help to someone. import * as net from "net"
import * as child_process from "child_process"
const server = net.createServer((socket) => {
// close the server and don't accept anymore connections
server.close();
socket.on("data", (message) => {
console.log(message.toString());
});
initialize(socket);
});
server.listen(3000, () => {
// ask the language server to connect to port 3000 once the setup has completed
child_process.spawn("node", [ "out/src/server.js", "--socket=3000" ]);
});
let messageId = 1;
function send(socket: net.Socket, method: string, params: object) {
let message = {
jsonrpc: "2.0",
id: messageId++,
method: method,
params: params
};
let json = JSON.stringify(message) + "\n";
let headers = "Content-Length: " + json.length + "\r\n\r\n";
socket.write(headers, "ASCII");
socket.write(json, "UTF-8");
}
function initialize(socket: net.Socket) {
send(socket, "initialize", {
rootPath: process.cwd(),
processId: process.pid,
capabilities: {
/* ... */
workspace: {
}
}
});
} |
Language server answers nothing if
--socket
option used. Is implementation broken?Ways to repeat. Install Language server, for example
npm install -g ocaml-language-server
Run it via command line
ocaml-language-server --socket=3000
Connect via telnet to server
It replays nothing on correct request.
If I change line https://github.com/Microsoft/vscode-languageserver-node/blob/master/server/src/main.ts#L1460-L1464
to
it replay with correct response
Is it known issue?
The text was updated successfully, but these errors were encountered: