Skip to content
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

Function call never yields result #6

Closed
berwyn opened this issue Mar 27, 2021 · 2 comments
Closed

Function call never yields result #6

berwyn opened this issue Mar 27, 2021 · 2 comments

Comments

@berwyn
Copy link

berwyn commented Mar 27, 2021

I have an Elgato WaveLink microphone, and the user-space software for that exposes a JSON-RPC interface to control the microphone. Using the following code, I can connect and attempt to issue a command against the software. The handler I directly register on the socket will log the message coming back just fine, but the awaited call never resolves. Any idea what could be causing this?

❯ deno --version
deno 1.8.1 (release, x86_64-pc-windows-msvc)
v8 9.0.257.3
typescript 4.2.2
import { createRemote } from './deps.ts';

console.log('Opening connection...');

const socket = new WebSocket('ws://127.0.0.1:1824');
socket.addEventListener('open', () => console.log('connection open'));
socket.addEventListener('message', message => console.debug(message)); // This will successfully log out the response
socket.addEventListener('error', error => console.error(error));
socket.addEventListener('close', () => console.log('connection closed'));

const remote = await createRemote(socket);
const appInfo = await remote.getApplicationInfo(); // This never resolves

console.log('Got app info:')
console.debug(appInfo);
@timonson
Copy link
Owner

timonson commented Mar 27, 2021

The handlers you registered directly are - under working conditions - unnecessary but I am sure you already knew this. You are using the right syntax and it should actually work. Did you try the ws example already? I only tested gentle_rpc on Linux yet but it should work on Windows, too. Please let me know if the examples don't work on your machine neither (with the exception of the BadResource error which will be fixed in the next deno version).

Otherwise, is there another way to replicate this behavior without the microphone?

Thanks!

EDIT:

Does the server respond with a valid RPC response object with an id? You should be able to check this with your message handler. It is important that the response has an id in this case, please check this.

@berwyn
Copy link
Author

berwyn commented Mar 28, 2021

Oh, good call on the response, I just checked the payload that returns and it seems to have id: 0 instead of the one that went on the request! The payload looks otherwise well-formed, so it seems like Elgato isn't correctly matching the id of the request with the response. Well, guess that's something to file with them. Thanks for the help!

That said, I did attempt to run the examples and they do not seem to work on Windows (at least on my machine) but that's something I can look into and PR separately :)

@berwyn berwyn closed this as completed Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants