Skip to Content
It is currently October 17th, 2019, 6:10 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: April 23rd, 2018, 1:08 am 
Offline
cat's pajamas

Joined: January 18th, 2005, 7:03 pm
Posts: 280
Location: UK.
I can't understand a way to test Webtofile. I need a small PAL script that will tell me if its working or not?

I'm trying to undderstand why the following code doesn't work - when it used to work before various Windows upgrades.

The following WebToFile code snippet works in the Browser, but when in a running PAL script, it is getting ignored.

If I put this in a browser, it works. It creates a Tweet of the currently playing song and puts it in the Twitter timeline.
http://my-broadcast-server/Scripts/AUTH/AUTH.TWITTER.php


That is, if I put the script into my Browser address bar, it runs fine, pushing the appropriate message to Twitter.
However, from within the PAL script, as shown, it gets ... ignored, or fails somehow, and I can find any way of logging what's happening.

Code:
// Execute the PHP file on your web host.
// The first parameter is the name of a meaningless text file. Provide a valid path and name.
// The second parameter is the URL of your PHP file to be executed.
WebToFile('F:\My Websites\QuantumRadio\Scripts\SAM\_SAM.dummy.txt','http://my-broadcast-server/Scripts/AUTH/AUTH.TWITTER.php');


This has happened since I upgraded to the very latest Windows 10.

Anybody have any ideas, please. This is a real mystery to me.

_________________
Robert Chalmers
Quantum Radio
robert@quantum-radio.net
Wasting away in Margaritaville... Image
Image
Streaming via SAM since 1986
@ShanghaiTimes


Top
 Profile  
Reply with quote  
PostPosted: April 23rd, 2018, 6:38 am 
Offline
cat's pajamas

Joined: January 18th, 2005, 7:03 pm
Posts: 280
Location: UK.
Half a working example.
The first one works. Copying a file from one place to the next.
The second one doesn't work, calling the php file to do the Twitter string.
As before, if I put the php file string in the browser URL bar, it works. It does it.

BUT - using WebToFile does not make it work. No errors, no messages, nothing.


Code:
//PAL script functions
{######################}
PAL.Loop := False; {Default value}
//If set to TRUE then script will restart when it reached the end
//This is almost equal to the "Restart" command in ASQ

//Basic queue functions
{######################}

// Configurables -- Change these to fit:


const File_Local  = 'e:\Archive\Duande.mp3';
const File_Remote = 'https://www.robert-chalmers.uk/mp3/Duande.mp3';
WebToFile(File_Local,File_Remote);

const pFile_Local  = 'C:\Apache24\htdocs\QuantumRadio\Scripts\SAM\_SAM.dummy.txt';
const pFile_Remote = 'https://broadcast-server.xxx/Scripts/AUTH/AUTH.TWITTER.php';
WebToFile(pFile_Local,pFile_Remote)
// As in,
//{ Build URL used to send command to SHOUTcast server }
//var URL : String;
//URL := 'http://admin:'+shoutcast_password+'@'+shoutcast_host+':'+shoutcast_port+'/admin.cgi?mode=kicksrc';

//{ Kick source from SHOUTcast server }
//WebToFile('c:\dummy.txt',URL);


_________________
Robert Chalmers
Quantum Radio
robert@quantum-radio.net
Wasting away in Margaritaville... Image
Image
Streaming via SAM since 1986
@ShanghaiTimes


Last edited by quantumradio on April 26th, 2018, 6:29 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: April 23rd, 2018, 6:54 am 
Offline
cat's pajamas

Joined: January 18th, 2005, 7:03 pm
Posts: 280
Location: UK.
I think I found it.
It doesn't like the https - but works when addressed with the http only.

I have CSP active on the https side.

_________________
Robert Chalmers
Quantum Radio
robert@quantum-radio.net
Wasting away in Margaritaville... Image
Image
Streaming via SAM since 1986
@ShanghaiTimes


Top
 Profile  
Reply with quote  
PostPosted: April 23rd, 2018, 8:38 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7878
Location: Aachen (Germany)
quantumradio wrote:
I have CSP active on the https side.

Yeah, that's nice for you, but PAL doesn't process JavaScript at all, so Content-Security-Policy has no effect.
Did you by chance mean HSTS instead? (Strict Transport Security forces the browser to use the HTTPS version of your site even if it tries to open the plain HTTP version) But that has no effect on PAL either. In fact PAL will ignore all HTTP Headers and just print the HTTP Body "as-is" to the harddisk with the WebToFile command.

HTTPS support is available as of SAM Broadcaster 2018.1

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: April 24th, 2018, 9:24 am 
Offline
cat's pajamas

Joined: January 18th, 2005, 7:03 pm
Posts: 280
Location: UK.
Thanks for getting back. The thing is, if I make the string
const pFile_Remote = 'https://quantum-radio.net.... It fails. In fact it does nothing. It's just ignored.
If however, I make it
const pFile_Remote = 'http://quantum-radio.net.... it works fine as one can see if you find my twitter feed @R_A_Chalmers, and look for the Quantum-Radio posts.

I have CSP as I mentioned, and HSTS, but only on the 443 side. Until I resolve this I can't be redirecting the 80 to the 443.
The thing is, the PAL stript, calls the PHP script. Scripts/AUTH/AUTH.TWITTER.php'; which processes all the stuff that puts the tweet into twitter...
It doesn't write the file to disk. Like the KickDJ PAL script, it actually runs the process. It's interesting because I can't find any evidence in any log file of it failing on the 443 side. It just fails.
I'll keep looking at it. I know it's a CSP thing, because the example script I use above to copy the mp3 file, uses https, and it works fine. Just not the script processing one. hmmm. I'll try another php script that does nothing. see what happens.

_________________
Robert Chalmers
Quantum Radio
robert@quantum-radio.net
Wasting away in Margaritaville... Image
Image
Streaming via SAM since 1986
@ShanghaiTimes


Top
 Profile  
Reply with quote  
PostPosted: April 24th, 2018, 5:29 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7878
Location: Aachen (Germany)
What version of SAM are you running?
SAM pre 2018.1 doesn't understand TLS and can't process encrypted websites/files/documents/whatever you want to call it.
It won't even be able to request anything from the server on HTTPS / port 443 as the server expects a TLS encrypted communication but won't receive that from SAM pre 2018.1.

Both CSP and HSTS are just headers sent by the server to tell the browser how it should process client side information.
SAM will ignore both of these.

If you open http://example.com (i.e. unencrypted plain HTTP) with enabled HSTS it will send a Header in the reply that tells the browser to instead call https://example.com (i.e. TLS-encrypted HTTPS), but SAM will ignore that header and still process the body of the plain HTTP request (just like any old browser without HSTS support would do).
Usually HSTS is combined with a forced redirect. All requests in plain text on port 80 will only get a redirect to the encrypted HTTPS version as a response and no actual content.
If that is the case, SAM can't process the site at all in versions prior to SAM 2018.1


With CSP regardless of whether you open http://example.com on Port 80 or https://example.com on Port 443 the server sends a header to tell the browser where it may load additional JavaScript resources. (i.e. scripts.example.net might be whitelisted that way, but scripts.example.org would not work).
However as SAM doesn't do any processing on the HTTP response body, this is of no interest at all to SAM. For SAM all HTTP responses are plaintext, regardless of what you write. It doesn't process HTML markup, no CSS, doesn't execute JavaScript (i.e. <script>alert('SAM is dumb');</script> will not open a dialog box in SAM when you download the file, it will only put that text into a text file)


If you absolutely must use HTTPS, upgrade to SAM 2018.1 or newer. That functionality isn't present at all in older SAM versions and won't be backported either.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: April 25th, 2018, 1:55 am 
Offline
cat's pajamas

Joined: January 18th, 2005, 7:03 pm
Posts: 280
Location: UK.
Ok. I'm running 2017.11 here. (What is the latest version by the way?) Not that it matters. I understand your comments above but reiterate.

Why does this work;
Code:
const File_Local  = 'e:\Archive\Duande.mp3';
const File_Remote = 'https://www.robert-chalmers.uk/mp3/Duande.mp3';
WebToFile(File_Local,File_Remote);


and this doesn't work.

Code:
const pFile_Local  = 'C:\Apache24\htdocs\QuantumRadio\Scripts\SAM\_SAM.dummy.txt';
const pFile_Remote = 'https://quantum-radio.net/Scripts/AUTH/AUTH.TWITTER.php';
WebToFile(pFile_Local,pFile_Remote)

_________________
Robert Chalmers
Quantum Radio
robert@quantum-radio.net
Wasting away in Margaritaville... Image
Image
Streaming via SAM since 1986
@ShanghaiTimes


Top
 Profile  
Reply with quote  
PostPosted: April 25th, 2018, 4:51 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7878
Location: Aachen (Germany)
Sorry, I definitely misread the first URL. To me it looked like the first one was a plain HTTP URL and only the second one was an encrypted one.

With that out of the way:
URL #1 is an Error 404 Not Found HTML page.
URL #2 is an empty document.

I know that 2017.11 did not officially support HTTPS and that the support was shaky (some algorithms or certificate authorities were not usable with the older HTTP library). I never used the stable version, though and was only testing several prerelease versions for that new THttpClient class for Spacial.


quantumradio wrote:
Ok. I'm running 2017.11 here. (What is the latest version by the way?)

http://download.spacial.com/changelog/s ... gelog.html
We also try to keep up with the changelog in the FAQ thread here on the forum where we include all the download links for previous SAM versions as well (We can't give any guarantee that they'll stay online, though. Spacial doesn't announce when they remove a download):
viewtopic.php?f=20&t=28106

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: April 25th, 2018, 7:15 am 
Offline
cat's pajamas

Joined: January 18th, 2005, 7:03 pm
Posts: 280
Location: UK.
Hi,
Thanks.
URL #1 requires the script to run so that it copies the mp3 file to the directory - it does, but I removed the file. It's back there now if you want to listen to the file - a bit of Spanish guitar. That was to prove to myself that WebtoFile does work.
URL #2 is not as empty as you might think... if you just put the URL into your browser. If I turn Debug on, you can see it's output. But I"d rather not do that publically. However, my problem is that URL #2 works on its own. But it does not work when part of the WebtoFile sequence in the script.
Actually, I don't think its anything to do with http, or https. I'll try another experiment with a few things disabled...

EDIT: Disabled CSP. Made no difference. I give up. I'll just send it through http, as that script won't do it through https.

_________________
Robert Chalmers
Quantum Radio
robert@quantum-radio.net
Wasting away in Margaritaville... Image
Image
Streaming via SAM since 1986
@ShanghaiTimes


Top
 Profile  
Reply with quote  
PostPosted: April 25th, 2018, 9:05 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7878
Location: Aachen (Germany)
quantumradio wrote:
URL #2 is not as empty as you might think... if you just put the URL into your browser. If I turn Debug on, you can see it's output. But I"d rather not do that publically. However, my problem is that URL #2 works on its own. But it does not work when part of the WebtoFile sequence in the script.

Yeah, I thought so.

I had completely forgotten what the reason was why SSL support was shaky in the 2017.8-11 builds.
But after investigating your websites more closely I realized they're both on the same server, but using different certificates.
That requires TLS-SNI support on the client and that's not available in SAM 2017.
You can only have one SSL certificate per domain without SNI.

Ways to get around that are:
#1 Upgrade SAM (will give you TLS-SNI support)
#2 Get a multi-domain certificate and make sure all hostnames on this IP use the same certificate (one certificate per IP, but noone makes any limits as to how many domains you may have in a single certificate)
#3 Make sure the server will always pick the certificate for the site you want to access via SAM if no hostname is supplied before the TLS/SSL session is established. (You won't be able to access other domains on the same IP using SAM or Internet Explorer on WinXP, but it will work for the "main" domain)

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: April 25th, 2018, 10:15 am 
Offline
cat's pajamas

Joined: January 18th, 2005, 7:03 pm
Posts: 280
Location: UK.
Yep, I must upgrade one day again. I'm not especially worried at the moment. I've been using SAM and streaming since at least 1989. My station short name with Spacial is [22-Radio Daze], the number says it all. The 22'nd stream registrant. The ong name of course is Quntum-Radio. Generally over the years its all functioned pretty well. I've dragged the whole lot from Australia to China to Australia to the UK over that period. Including from one end of Australia to the other.
So when I get little niggles like this, what can one do? Thanks for the time. Cheers

_________________
Robert Chalmers
Quantum Radio
robert@quantum-radio.net
Wasting away in Margaritaville... Image
Image
Streaming via SAM since 1986
@ShanghaiTimes


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group