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.

Error connecting to voice on Raspberry Pi

See original GitHub issue

I haven’t had time to test this on another Linux device yet, but I know my code works fine on Windows.

When my bot tries to connect to voice, although actually connecting to the channel succeeds, opening the audio connection fails.

The following error occurs:

java.lang.NullPointerException
        at net.dv8tion.jda.audio.AudioWebSocket.send(AudioWebSocket.java:110)
        at net.dv8tion.jda.audio.AudioWebSocket.onConnected(AudioWebSocket.java:124)
        at com.neovisionaries.ws.client.ListenerManager.callOnConnected(ListenerManager.java:189)
        at com.neovisionaries.ws.client.WebSocket.callOnConnectedIfNotYet(WebSocket.java:3207)
        at com.neovisionaries.ws.client.WebSocket.onReadingThreadStarted(WebSocket.java:3152)
        at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:80)
        at com.neovisionaries.ws.client.ReadingThread.run(ReadingThread.java:61)
Exception in thread "Thread-5" Exception in thread "Thread-6" java.lang.NullPointerException
        at net.dv8tion.jda.audio.AudioConnection$3.run(AudioConnection.java:224)
java.lang.NullPointerException
        at net.dv8tion.jda.audio.AudioConnection$2.run(AudioConnection.java:151)

Other than that, I’d like to say that this API is brilliant and really easy to use, so thanks for all the hard work.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DV8FromTheWorldcommented, Apr 22, 2016

Going to assume this fixes the problem for both parties. @FrozenDroid If the problem persists for you please reopen this issue.

0reactions
DV8FromTheWorldcommented, Apr 22, 2016

https://github.com/DV8FromTheWorld/JDA/commit/329b3e231db43a14057d62e31a77240f75ea94c4 A race condition like I thought. Basically, the onConnect method was being called during the connect() method’s execution. Connect runs in the thread it is called from, but the onConnect method is handled by the websocket thread, which is a different thread. This means that the onConnect can be executed before connect() returns. We were using the return from connect() to populate our socket variable which is used in the send(String) method. So, since connect() hadn’t returned, using the socket variable, which was still null, was throwing an NPE.

I changed it so that we set the socket variable before attempting to connect. We had the same problem with the Main WebSocket, this specific race condition. However, it was a LOOONG time ago, so I guess I forgot to implement the fix in the AudioWebSocket when I created it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bluetooth PulseAudio problem- please help.
Hi, I've got a got Raspberry Pi in my van, it used to connect up via bluetooth to radio system so I could...
Read more >
How to Make your Raspberry Pi Speak Out Loud: Give It a Voice!
Give your Raspberry Pi a voice. In this tutorial we show how to make your Raspberry Pi Speak out loud and say simple...
Read more >
Voice Recognition Raspberry PI and Arduino UART ...
High quality PCB prototypes: https://www.pcbway.com3D & CNC service: https://www.pcbway.com/rapid-prototyping/ Recognise voice with ...
Read more >
Raspberry Pi Quick Start Guide | Alexa Voice Service
Complete the following step-by-step instructions to set up the Alexa Smart Screen SDK on a Raspberry Pi running Debian Buster. The instructions guide...
Read more >
Raspberry Pi Alexa: Build your own Amazon Echo
This screen is the area that will allow us to set up access for our Raspberry Pi to connect to the Alexa voice...
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