• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • Happy New Year everyone! A new version (1.0.0-beta.16) is out for Linux, fixing an issue that could lock the bot up when using it with TS3. Please visit the resources section or the main page (https://www.sinusbot.com) for the new package.

require('ws') returns undefined

jonom

Member
SinusBot version: 1.0.0-beta.16-ba60e37
TS server version: 3.13.6 Linux
OS: Linux jmus-0 5.13.0-1028-oracle #33~20.04.1-Ubuntu SMP Mon May 2 03:53:18 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
sinusbot is running in a docker container. the docker image is the recommended sinusbot/docker. (this is also the reason I did not use the diagnostic script)
hardware: vps
2022-05-25T02:55:31+02:00 error on callback func: Uncaught exception: TypeError: Cannot read property 'broadcast' of undefined at app-ws:20:7 ws.broadcast(1, { blubb: 'blubb' }); ^ Stack trace: TypeError: Cannot read property 'broadcast' of undefined at event.on.id (app-ws:20:8)
2022-05-25T02:55:31+02:00 [ app-ws:18:12] new websocket connection; id 60867ca003f6a4ba
2022-05-25T02:54:09+02:00 New connection status 4; Error 0
2022-05-25T02:54:09+02:00 TS |INFO |ClientUI |1 |Connect status: Connection established
2022-05-25T02:54:09+02:00 New connection status 3; Error 0
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI |1 |Connect status: Establishing connection
2022-05-25T02:54:08+02:00 New connection status 2; Error 0
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI |1 |Connect status: Connected
2022-05-25T02:54:08+02:00 TS |DEVELOP |PktHandler |1 |Puzzle solve time: 83
2022-05-25T02:54:08+02:00 New connection status 1; Error 0
2022-05-25T02:54:08+02:00 TS |INFO | | |Statistics report: User has not yet confirmed participation
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI | |Last update check was: Mon Jan 1 00:00:01 2035
2022-05-25T02:54:08+02:00 TS |INFO |Bookmarks | |Collecting autoconnect bookmarks
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI |1 |Connect status: Connecting
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI |1 |Initiating connection: 172.20.19.10:9987
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI |1 |Resolve successful: 172.20.19.10:9987
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI |1 |Lookup finished: ip=172.20.19.10 port=9987 query=teamspeak.docker.local error=0
2022-05-25T02:54:08+02:00 TS |INFO |TSDNS | |SRV DNS resolve unsuccessful, "_ts3._udp.teamspeak.docker.local" Domain name not found
2022-05-25T02:54:08+02:00 TS |INFO |TSDNS | |SRV DNS resolve unsuccessful, "_tsdns._tcp.docker.local" Domain name not found
2022-05-25T02:54:08+02:00 TS |INFO |TSDNS | |A/AAAA DNS resolve unsuccessful, "docker.local" Domain name not found
2022-05-25T02:54:08+02:00 TS |INFO |TSDNS | |No TSDNS found
2022-05-25T02:54:08+02:00 TS |INFO |TSDNS | |TSDNS queried unsuccessfully 172.20.19.10:41144
2022-05-25T02:54:08+02:00 TS |INFO |TSDNS | |A/AAAA DNS resolve for possible TSDNS successful, "teamspeak.docker.local" =(h: 172.20.19.10 p:0)
2022-05-25T02:54:08+02:00 TS |INFO |TSDNS | |A/AAAA DNS resolve successful, "teamspeak.docker.local" =(h: 172.20.19.10 p:0)
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI |1 |Trying to resolve teamspeak.docker.local
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI |1 |Connect to server: teamspeak.docker.local
2022-05-25T02:54:08+02:00 TS |INFO |ClientUI | |ts3server: teamspeak.docker.local?port=9987&nickname=Kein%20Bot&password=&cid=37&channelpassword=
2022-05-25T02:54:07+02:00 TS |INFO |ClientUI | |Using configuration location: /opt/sinusbot/data/ts3/13870b3c-9b0a-458b-9c6f-1ed166747922/8680b0a5-6735-4cfd-a90d-af9b35a47186/settings.db
2022-05-25T02:54:07+02:00 TS |INFO |ClientUI | |Qt version: 5.12.1
2022-05-25T02:54:07+02:00 TS |INFO |ClientUI | |Failed to init text to speech engine
2022-05-25T02:54:07+02:00 TS |INFO | | |*** Time [INIT]: 1276
2022-05-25T02:54:07+02:00 TS |INFO | | |*** Time [MAINWINDOW]: 1275
2022-05-25T02:54:07+02:00 TS |INFO | | |*** Time [SERVERVIEWMANAGER]: 158
2022-05-25T02:54:07+02:00 Could not send config: HTTP returned an error: Error; Code: 500; Message: Error
2022-05-25T02:54:07+02:00 TS |INFO |Plugins | |Loading plugin: libsoundbot_plugin.so
2022-05-25T02:54:07+02:00 TS |INFO |Query | |listening on 127.0.0.1:25639
2022-05-25T02:54:07+02:00 TS |INFO |Plugins | |Loading plugin: libclientquery_plugin_linux_amd64.so
2022-05-25T02:54:07+02:00 TS |INFO |Addons | |Checking for addon updates...
2022-05-25T02:54:07+02:00 TS |INFO | | |*** Time [ICONMANGER]: 812
2022-05-25T02:54:06+02:00 TS |INFO | | |successfully downloaded revocation list for myteamspeak id
2022-05-25T02:54:06+02:00 TS |INFO | | |successfully downloaded revocation list for accounting
2022-05-25T02:54:06+02:00 TS |ERROR |RevocationListCache| |Failed to import revocation list from cache
2022-05-25T02:54:06+02:00 TS |INFO |ClientUI | |Unable to create an Open GL context.
2022-05-25T02:54:06+02:00 TS |ERROR |SoundBckndIntf| |libpulse.so.0: cannot open shared object file: No such file or directory
2022-05-25T02:54:06+02:00 TS |INFO | | |Using hardware aes
2022-05-25T02:54:06+02:00 TS |INFO | | |SystemInformation: Linux 5.13.0-1028-oracle #33~20.04.1-Ubuntu SMP Mon May 2 03:53:18 UTC 2022 x86_64 Binary: 64bit
2022-05-25T02:54:06+02:00 TS |INFO | | |TeamSpeak Client 3.5.6 (2020-11-25 13:53:42)
2022-05-25T02:54:03+02:00 Starting instance ts3server://teamspeak.docker.local?port=9987&nickname=Kein%20Bot&password=&cid=37&channelpassword=
2022-05-25T02:54:03+02:00 Could not create Notifications-Tabletable Notifications already exists
2022-05-25T02:54:03+02:00 Could not create WhisperReceive-Tabletable WhisperReceive already exists
2022-05-25T02:54:03+02:00 Could not create Chat-Tabletable Chat already exists
2022-05-25T02:54:03+02:00 script app-ws loaded
2022-05-25T02:54:03+02:00 [ app-ws:14:8] undefined
2022-05-25T02:54:03+02:00 script alonemode loaded
2022-05-25T02:54:03+02:00 script Default-Channel loaded
2022-05-25T02:54:03+02:00 script kasimir loaded
2022-05-25T02:54:03+02:00 connecting to db: sinusbot:[email protected](mysql.docker.local:3306)/TeamSpeak 3 Bot
2022-05-25T02:54:03+02:00 script join2 loaded
2022-05-25T02:54:03+02:00 connecting to db: sinusbot:[email protected](mysql.docker.local:3306)/TeamSpeak 3 Bot
2022-05-25T02:54:03+02:00 script activites loaded
2022-05-25T02:54:03+02:00 connecting to db: sinusbot:[email protected](mysql.docker.local:3306)/TeamSpeak 3 Bot
2022-05-25T02:54:03+02:00 script steamreport loaded
2022-05-25T02:54:03+02:00 connecting to db: sinusbot:[email protected](mysql.docker.local:3306)/TeamSpeak 3 Bot
2022-05-25T02:54:03+02:00 script stats loaded
2022-05-25T02:54:02+02:00 connecting to db: sinusbot:[email protected](mysql.docker.local:3306)/TeamSpeak 3 Bot
2022-05-25T02:54:02+02:00 Auto-Starting 13870b3c-9b0a-458b-9c6f-1ed166747922/8680b0a5-6735-4cfd-a90d-af9b35a47186 in 500 ms...
2022-05-25T02:54:02+02:00 Initialization complete
2022-05-25T02:54:02+02:00 script OKlib loaded
2022-05-25T02:54:02+02:00 script sinusbot-commands loaded
2022-05-25T02:54:02+02:00 [sinusbot-commands:114:12] SinusBot v1.0.0-beta.16-ba60e37 on linux
2022-05-25T02:54:02+02:00 [sinusbot-commands:113:12] Loaded SinusBot Commands v1.1.2 by Jonas Bögle (@irgendwr).
2022-05-25T02:54:02+02:00 script command loaded
2022-05-25T02:54:02+02:00 Loading instance://2e2664d4-839d-4030-83d5-9b18068bb606
2022-05-25T02:54:02+02:00 Loading instance://8680b0a5-6735-4cfd-a90d-af9b35a47186
2022-05-25T02:54:02+02:00 Loading instances
INI:
TS3Path = "/opt/sinusbot/teamspeak3-client/ts3client_linux_amd64"
ListenHost = "0.0.0.0"
DataDir = "/opt/sinusbot/data/"
ListenPort = 8087
LocalPlayback = false
EnableLocalFS = false
MaxBulkOperations = 300
LogLevel = 10
EnableProfiler = false
YoutubeDLPath = "/usr/local/bin/youtube-dl"
EnableDebugConsole = false
EnableInternalCommands = false
AllowStreamPush = false
UploadLimit = 83886080
RunAsUser = 0
RunAsGroup = 0
ExternalFileBase = ""
InstanceActionLimit = 6
UseSSL = false
SSLKeyFile = ""
SSLCertFile = ""
Hostname = ""
HostnameMask = ""
SampleInterval = 60
StartVNC = false
EnableWebStream = false
LogFile = ""
LicenseKey = "XXX"
IsProxied = false
DenyStreamURLs = []
Pragma = 0
UserAgent = ""

[YoutubeDL]
  BufferSize = 524288
  MaxDownloadSize = 419430400
  MaxDownloadRate = 104857600
  MaxSimultaneousChunkDownloads = 6
  CacheStreamed = false
  TimeoutSingleDownloader = 0
  TimeoutMultiDownloader = 0
  ChunkSize = 3145728

[TS3]
  AvatarMaxWidth = 0
  AvatarMaxHeight = 0
  AllowGIF = false

[StreamRewrites]

[Scripts]
  Debug = false
  AllowReload = false
  EnableTimer = false
  DisableLegacyEvents = false
  DevMode = false
  ScriptTimeout = 5

[Themes]
  Default = ""

[SpeechRecognition]
  Enable = false

[FFmpeg]
  UserAgent = "SinusBot (1.0.0-beta.10-202ee4d)"
  WaitTime = 0

[DAV]
  Enable = false

[XServer]
  Delay = 0
  Debug = false

[SHMem]
  Enable = false
  Size = 0
  Delay = 0
  Interval = 0

[RadioStations]
  URL = ""
  UpdateInterval = 0

[TTS]
  Enabled = false
ws-app plugin (basically a copied the docs):
JavaScript:
registerPlugin({
    name: 'ws-app',
    engine: '>= 0.13.37',
    version: '1.0.0',
    description: 'open ws for tsviewer app',
    author: '',
    requiredModules: ["ws"],
    vars: []
}, function (_, config) {
    const engine = require('engine');
    const event = require('event');
    const ws = require('ws');

    engine.log(require('ws'));

    // listen for connections
    event.on('ws.connect', id => {
        engine.log('new websocket connection; id ' + id);
        // broadcast data to all connected clients
        ws.broadcast(1, { blubb: 'blubb' });
    });
    // listen for disconnections
    event.on('ws.disconnect', id => {
        engine.log('websocket connection disconnected; id ' + id);
    });
    // listen for data
    event.on('ws.data', (id, type, data) => {
        engine.log('ws.data: id ' + id + '; data: ' + data.toString());
        // respond with data
        ws.write(id, type, data.toString());
    });
});

As can be seen in the instance logs require('ws') returns undefined. However, when connecting the event gets triggered as expected. It's very possible I made a stupid mistake, but I do not see it now.
 
Last edited:
Top