Author Topic: Trouble streaming audio from dropbox  (Read 361 times)

QuentinC

  • Posts: 74
Trouble streaming audio from dropbox
« on: 28 Aug '21 - 20:25 »
Hello,

Many users of my program share dropbox URLs in order to listen to music or various recordings while they are chatting or playing to my game.
This is quite a fairly common practice and well beloved feature since I offer this possibility.

The pasted URLs look like the following:
https://www.dropbox.com/s/xxxxxxxxxxx/xxxxxxx.mp3?dl=1
(This link is obviously a fake one, I'm waiting for approval of the player to post a  true link)


In my program, while the stream is perfectly played when using BASS 2.4.14, the exact same link no longer work with BASS 2.4.16. I get error 2.

The strange thing is, if I test always the exact same link in the netradio example, it works neither with BASS 2.4.14 or 2.4.16. Both give error 2.

BY examining more closely what's going on by looking at what's returned by the downloadproc, I can observe that:

1. Upon callig BASS_StreamCreateURL, a first HTTP request is sent
2. Dropbox replies with a HTTP 301 redirection, as far as I can see with exactly the same URL
3. BASS follows the redirection and try again
4. Dropbox again replies with another redirection, again with the same URL, but HTTP code 302 this time
5. BASS again follows the redirection
6. This time, dropbox replies with HTTP 400 bad request
7. With BASS 2.4.14, BASS_StreamCreateURL returns normally and the audio starts playing; with BASS 2.4.16, BASS_StreamCreateURL returns NULL and BASS_ErrorGetCode returns 2.

That's exactly the same program, the same URL, on the same system (win10), so it looks like something has changed between BASS 2.4.14 and 2.4.16.
By the way, I also tried http instead of https and the behavior is the same (so the problem isn't https-related).
It doesn't seem to be specifically related to MP3 or another format, as the problem occurrs equally with MP3 or OGG files as far as I have tested.


I suspect that BASS didn't check HTTP status code in 2.4.14 and tried anyway to play whatever was sent by the server, while in 2.4.16 it now checks the status code and promptly returns when it sees that it isn't 200.
If this is indeed what's happen, would it be possible to add a flag or a config option to tell BASS to try playing the stream regardless of the failure status code ?
It looks like despite error 400, the audio is still downloaded correctly, since BASS 2.4.14 is able to play it.

If what I'm  supposing is wrong, what could have changed between BASS 2.4.14 and 2.4.16 ? Can I do something about it ?

Thank you for your answers.


EDIT: here's true links to test
https://www.dropbox.com/s/8xmju1f4o6deznm/mustart.ogg?dl=1
https://www.dropbox.com/s/7ngqrk6cxq6djna/Rainbow%20tower%20complete.mp3?dl=1
Please use these links wisely, dropbox blocks when there are too many requests.

Thank you.
« Last Edit: 28 Aug '21 - 20:48 by QuentinC »

Ian @ un4seen

  • Administrator
  • Posts: 23924
Re: Trouble streaming audio from dropbox
« Reply #1 on: 30 Aug '21 - 16:05 »
The problem is that the final redirection URL from dropbox has a '#' at the end. They (and anything that follows) shouldn't be included in the request sent to the server, but BASS wasn't expecting to ever see them in a redirection and so it wasn't checking for them. Here's an update that does check for them and remove them from the request:

   www.un4seen.com/stuff/bass.zip

Let me know if you still see the problem happening with any URLs.

QuentinC

  • Posts: 74
Re: Trouble streaming audio from dropbox
« Reply #2 on: 30 Aug '21 - 17:16 »
Hello,

It works now with the above links.
I'll now send an update to testing users and let you definitely know in a few days if everything is fine.

Thank you very much for the very quick fix !

QuentinC

  • Posts: 74
Re: Trouble streaming audio from dropbox
« Reply #3 on: 7 Sep '21 - 20:12 »
Hello,

No user complained any longer with this problem this week, so I think we can consider it as being definitely fixed.

Thank you very much for  fixing it so quickly.

Ian @ un4seen

  • Administrator
  • Posts: 23924
Re: Trouble streaming audio from dropbox
« Reply #4 on: 8 Sep '21 - 14:56 »
Great! An update (2.4.16.7) including this fix and a few other little tweaks'n'fixes is up now on the BASS page.