Author Topic: BASS_StreamCreateUrl returning 0 with BASS_ERROR_FILEOPEN on linux docker contai  (Read 515 times)

Frederik

  • Guest
Hello,

I'm encountering a bizarre issue while developing a .netcore app using Bass.NET. When running on Windows all streams opened with StreamCreateUrl work as expected.
When it runs in a linux docker container one of the streams I test with returns BASS_ERROR_FILEOPEN.

I'm testing with these urls :

http://icecast.vrtcdn.be/stubru-high.mp3 DOES NOT WORK ON LINUX
https://20043.live.streamtheworld.com:443/WILLY.mp3 WORKS

Is it because of the unsecured url which maybe isn't allowed on Linux ?

Any thoughts ?

Regards,
Frederik

Ian @ un4seen

  • Administrator
  • Posts: 23924
icecast.vrtcdn.be has multiple IPs and it may be that one or more of them is down. The current Linux BASS release will only try one IP but the latest build will try the others too, so you could give that a try. It's available here:

   www.un4seen.com/stuff/bass-linux.zip

Let me know if you still have the problem with that.

FredVDB

  • Posts: 4
Hello,

thank you for the quick response.

Unfortunately the problem remains with the mp3 url. Same issue with the AAC url http://icecast.vrtcdn.be/stubru.aac from that same server.
In fact all urls from that host don't work (https://www.vrt.be/nl/aanbod/kijk-en-luister/radio-luisteren/streamingslinks-radio/)

How were you able to detect that multiple IP addresses were linked to that domain name ?

Regards,
Frederik

Ian @ un4seen

  • Administrator
  • Posts: 23924
That is strange then, as the URL is working on Linux here. Actually, I see it is also working with the release BASS version, so probably not a dead IP issue as I speculated. Are you having the problem only on that particular Linux installation, or elsewhere too? Are you using a custom BASS_CONFIG_NET_AGENT setting? If so, you could try leaving the default in case yours is getting rejected/blocked by the server. If the problem persists, please try setting the BASS_STREAM_STATUS flag and checking what (if any) headers are received in your DOWNLOADPROC callback function. An example of doing this can be seen in the NETRADIO.C example included in the BASS package.

Regarding checking for multiple IPs, you can do a DNS lookup. For example, here:

   https://toolbox.googleapps.com/apps/dig/

FredVDB

  • Posts: 4
I have tried with and without a specific NET_AGENT string, but no avail.
Same behavior on Linux with BASS_STREAM_STATUS. It returns 0 with same error code.
On Windows (using the same stream url) the DOWNLOADPROC returns "HTTP/1.1 200 OK".

The streaming url which works on both Linux and Windows returns HTTP/1.0 200 OK

FredVDB

  • Posts: 4
Hello Ian,

I managed to get it working. The cause was the OS the container was based on. Default dockerfile in Visual Studio uses a Debian OS. I switched to Alpine and everything worked.

Thanks for your help.

Ian @ un4seen

  • Administrator
  • Posts: 23924
Good to hear that you have it working now. Still curious that it wouldn't work on the previous Linux installation. If you happen to still have that other installation, please capture the network traffic to have a look at. You can do that with tcpdump. For example:

   tcpdump tcp -s 0 -w traffic.pcap
   
And then upload the traffic.pcap file here:

   ftp.un4seen.com/incoming/

FredVDB

  • Posts: 4
I tried the tcpdump command, but ended up with an empty file, so it looked like there even was no network activity. (I double checked with the working url which captured packets).

if someone else should encounter the same problem : it did not work using container mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim
It works with container mcr.microsoft.com/dotnet/core/runtime:3.1-alpine


vadd98

  • Guest
Hi,
I am getting the same issue in a docker image based on Ubuntu 20.04 Focal and the latest libbass.so.
Everything works fine except StreamCreateUrl, which always returns 0. The same project on an Ubuntu 20.04 Focal Desktop installation works fine.
I tried to use an Alpine image instead of the Ubuntu one and there StreamCreateUrl works correctly.
By the way, I need to use an Ubuntu/Debian image because I need glibc, which is not available in Alpine images.

Is there any way to overcome this issue?

Ian @ un4seen

  • Administrator
  • Posts: 23924
To narrow down what the problem is, please first check the error code (after the failed BASS_StreamCreateURL call) with BASS_ErrorGetCode. If it's 2 (BASS_ERROR_FILEOPEN) then please also capture the network traffic to see what's being sent and received. You can do that with tcpdump. For example:

   tcpdump tcp -s 0 -w traffic.pcap
   
And then upload the traffic.pcap file here:

   ftp.un4seen.com/incoming/

vadd98

  • Guest
I've just uploaded it on the ftp.
I'll wait for news, thanks

Ian @ un4seen

  • Administrator
  • Posts: 23924
I forgot to say, please use an "http" URL (rather that "https") so that the request and response is visible in the network capture. Also confirm what error code you're getting.

vadd98

  • Guest
You're right, I didn't say what was the error. I confirm that the error is BASS_ERROR_FILEOPEN.
About the streaming, at the moment I just have https streams because I'm working for some third-party radios that only stream via https. I'll try to find an http stream and update the topic

Ian @ un4seen

  • Administrator
  • Posts: 23924
You can get some HTTP stream URLs to try from the http://dir.xiph.org/ listings.

If the problem is only happening with a particular HTTPS stream then another way to get more info is to use the BASS_STREAM_STATUS flag to receive the response headers. For example, something like this:

Code: [Select]
stream = BASS_StreamCreateURL(url, 0, BASS_STREAM_STATUS, DownloadProc, 0);

...

void DownloadProc(const void *buffer, DWORD length, void *user)
{
if (buffer && !length) { // got HTTP/ICY headers
const char *p = (const char*)buffer;
while (*p) {
printf("%s\n", p); // display header
p += strlen(p) + 1; // next header
}
}
}

vadd98

  • Guest
I made some other tests. With my old https link, i get the error BASS_ERROR_FILEOPEN and the stream is 0. The DownloadProc is never called (I tested the same code on desktop and on Alipne and the DownloadProc works correctly reporting the headers, so I think it is not a coding problem).

I tried than with an http link from the url you linked and I got this:

Quote
[13:23:24 INF] DownloadProc message: HTTP/1.0 200 OK
Server: Icecast 2.4.2
Date: Sat, 02 Oct 2021 11:23:24 GMT
Content-Type: audio/aacp
Cache-Control: no-cache
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Access-Control-Allow-Origin: *
X-Robots-Tag: none
icy-br:128
ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2
icy-br:128
icy-description:A zene Benned van!
icy-genre:House, Dance, Trance
icy-name:RADIO INSIDE
icy-pub:1
icy-url:http://www.radioinside.hu
icy-metaint:16000
[13:23:25 INF] DownloadProc message: HTTP/1.0 200 OK
Server: Icecast 2.4.2
Date: Sat, 02 Oct 2021 11:23:25 GMT
Content-Type: audio/aacp
Cache-Control: no-cache
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Access-Control-Allow-Origin: *
X-Robots-Tag: none
icy-br:128
ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2
icy-br:128
icy-description:A zene Benned van!
icy-genre:House, Dance, Trance
icy-name:RADIO INSIDE
icy-pub:1
icy-url:http://www.radioinside.hu
icy-metaint:16000
[13:23:25 INF] Initiliazing stream 0 but got the error code: BASS_ERROR_FILEFORM.

Here the DownloadProc is called, it seems fine, but the handle remains 0, so I can't continue.

Ian @ un4seen

  • Administrator
  • Posts: 23924
I made some other tests. With my old https link, i get the error BASS_ERROR_FILEOPEN and the stream is 0. The DownloadProc is never called (I tested the same code on desktop and on Alipne and the DownloadProc works correctly reporting the headers, so I think it is not a coding problem).

If the DOWNLOADPROC is never called then it looks like either the IP address couldn't be resolved (if the URL has a hostname) or the host refused connection. Are you able to open/play the same URL with other software on the same system?

I tried than with an http link from the url you linked and I got this:

Quote
[13:23:24 INF] DownloadProc message: HTTP/1.0 200 OK
Server: Icecast 2.4.2
Date: Sat, 02 Oct 2021 11:23:24 GMT
Content-Type: audio/aacp
...
[13:23:25 INF] Initiliazing stream 0 but got the error code: BASS_ERROR_FILEFORM.

Here the DownloadProc is called, it seems fine, but the handle remains 0, so I can't continue.

The issue in this case is that the stream is in AAC format, which isn't supported as standard on Linux (hence the BASS_ERROR_FILEFORM error). The BASS_AAC add-on will be needed to play it (load that via BASS_PluginLoad).

vadd98

  • Posts: 5
The problem is that the same url works correctly on the same code on any desktop or Docker Alpine images. Only on Ubuntu or Debian based Docker images it doesn't work and the DownloadProc is never called, but the code is exactly the same

Ian @ un4seen

  • Administrator
  • Posts: 23924
Does the URL contain a hostname or an IP address? If the former, perhaps it's a nameserver config issue in the docker image? Try looking up the IP address and replace the hostname with that in the URL, and see if it still fails then.

vadd98

  • Posts: 5
I just tried with the IP instead of the hostname, both with http and https, and in Docker Ubuntu it doesn't work. I got the error BASS_ERROR_FILEOPEN.
The streaming in my case is in MP3 format.
By the way, the same url works on the same code on Desktop.

EDIT:
I did some other tests with other mp3 urls and they all works.
I tried again my url with both http/https and both hostname/ip but none of them work, I always get the error BASS_ERROR_FILEOPEN.
The very strange thing is that the same url works outside Docker or in Alpine containers
« Last Edit: 5 Oct '21 - 10:10 by vadd98 »

Ian @ un4seen

  • Administrator
  • Posts: 23924
Please get a network capture from when trying the HTTP URL (not HTTPS).

vadd98

  • Posts: 5
I just uploaded the new network capture with the http url (using the ip, not the hostname).
I tried to open the pcap file looking for the streaming url, but it seems that it is never called.

If it could be useful for some debug, I can send you privately the url

Ian @ un4seen

  • Administrator
  • Posts: 23924
Yes, please PM me the URL to have a look at.

Ian @ un4seen

  • Administrator
  • Posts: 23924
For anyone else that encounters this issue, it turns out that it was caused by the /etc/services file being missing, which means the default port info isn't available to the getaddrinfo function and it fails when a port number isn't included in the URL. On Ubuntu, the /etc/services file is provided by the netbase package, so the solution is to install that.

In future, the default port numbers will be hardcoded in BASS to avoid the need for the /etc/services file.