question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JitsiConference.sendMessage() throws error when trying to send custom 'json-message'

See original GitHub issue

Description

When I try to send an object through the method sendMessage() of the class JitsiConference I receive an error. The error also appears to be present at the current meet.jit.si deployment.

lib-jitsi-meet.min.js:1 Uncaught TypeError: Cannot read property 'appendChild' of null
    at Builder.c (lib-jitsi-meet.min.js:1)
    at E.sendMessage (lib-jitsi-meet.min.js:10)
    at ie.sendTextMessage (lib-jitsi-meet.min.js:10)
    at ie.sendMessage (lib-jitsi-meet.min.js:10)
    at <anonymous>:1:6

The documentation hints that this should be possible:

// JitsiConference.js:2636
/**
 * Sends a message to a given endpoint (if 'to' is a non-empty string), or
 * broadcasts it to all endpoints in the conference.
 * @param {string} to The ID of the endpoint/participant which is to receive
 * the message, or '' to broadcast the message to all endpoints in the
 * conference.
 * @param {string|object} message the message to send. If this is of type
 * 'string' it will be sent as a chat message. If it is of type 'object', it
 * will be encapsulated in a format recognized by jitsi-meet and converted to
 * JSON before being sent.
 * @param {boolean} sendThroughVideobridge Whether to send the message through
 * jitsi-videobridge (via the COLIBRI data channel or web socket), or through
 * the XMPP MUC. Currently only objects can be sent through jitsi-videobridge.
 */
JitsiConference.prototype.sendMessage = function(
        message,
        to = '',
        sendThroughVideobridge = false) { ...

Current behavior

  • The payload is correctly converted into a JSON string and the elementType is set to json-element
  • The Strophe.Builder throws an error and the payload is not sent.

Expected Behavior

  • The payload is correctly converted into a JSON string and the elementType is set to json-element
  • The Strophe.Builder throws no error and the payload is sent.

Steps to reproduce

  1. goto https://meet.jit.si/
  2. start a random conference and join the room
  3. open the developer console
  4. send a message through the conference

window.APP.store.getState()["features/base/conference"].conference.sendMessage({foo: "bar"})

Environment details

Chrome, importing lib-jitsi-meet from self-hosted server.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
damenchocommented, May 2, 2021

Please, when you have questions or problems use the community forum before opening new issues, thank you.

window.APP.store.getState()["features/base/conference"].conference.sendMessage('some message')

0reactions
martinemmertcommented, May 2, 2021

@daimoc thanks for reopening this issue and take the time to have a second look.

I identified the .up() method which is called after the .c() method, that attaches the json-message node as the reason for this error message.

let m = $msg({ to: "foobar", type: "groupchat" });
m.c("json-message", { xmlns: '...' }, "{ "foo": "bar" }");
// Builder {nodeTree: message, node: message}
m.c("json-message", { xmlns: '...' }, "{ "foo": "bar" }").up()
// Builder {nodeTree: message, node: null}

The documentation of Strophe.Builder.c() says:

Add a child to the current element and make it the new current element.

This function moves the current element pointer to the child, unless text is provided. If you need to add another child, it is necessary to use up() to go back to the parent in the tree.

This appears to be not the case and the documentation is miss leading. If you provide a string or number the method c() behaves like t()

c (name, attrs, text) {
    const child = Strophe.xmlElement(name, attrs, text);
    this.node.appendChild(child);
    if (typeof text !== "string" && typeof text !=="number") {
        this.node = child;
    }
    return this;
}

// ...

t (text) {
    const child = Strophe.xmlTextNode(text);
    this.node.appendChild(child);
    return this;
}

I don’t have a correctly set up lib-jitsi-meet setup currently, therefore I can’t create a propper push requests with tests.


We prefer even bugs to first discuss them in the community forum, so in the future please do that.

You are doing a great job with the software, and I see your effort in giving good answers and be helpful in the forum. I searched for about 2 hours through the forum and was not sure this is the right place to discuss actual bugs. It appears to be a place where people ask for consultancy and don’t discuss issues like that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lib-jitsi-meet JItsiConference.sendMessage performance
Hi, I am develope whiteboard with lib-jitsi-meet with custom jitsi-server which installed by docker. When i send drawing messages to room.
Read more >
Jitsi
When I try to send an object through the method sendMessage() of the class JitsiConference I receive an error. The error also appears...
Read more >
feat(polls) Ability to create polls inside Jitsi #9166
We could send custom XMPP messages using Strophe. · We could use the “sendMessage” method on the lib-jitsi-meet conference object to send “endpoint...
Read more >
How to get specific error instead of Internal Server Error?
Let's say I have my controller and I implicitly throw an exception. @RestController public class HelloWorldController { @GetMapping("/hello- ...
Read more >
lib-jitsi-meet API (low level) - GitHub Pages
After you receive the CONNECTION_ESTABLISHED event you are to create the JitsiConference object and also you may want to attach listeners for conference ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found