EnglishУкраїнськаmRussian
Login/New
Topic with no new replies

[BugWrong] HTTP Socket Error


Author Message
Written on: 13. 03. 2023 [20:39]
diegoeck
Diego Eckhard
Developer
Topic creator
registered since: 25.02.2022
Posts: 5
I'm trying to acces san HTTP API using Socket HTTP with code:

req=SYS.XMLNode("GET");
req.setAttr("URI","/index.php");
SYS.Transport.Sockets.out_testHTTP.messIO(req,"HTTP");
textout=req.text();

and I'm getting the message in variable textout:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>400 Bad Request</title> </head><body> <h1>Bad Request</h1> <p>Your browser sent a request that this server could not understand.<br /> </p> <hr> <address>Apache/2.4.54 (Debian) Server at 172.18.0.3 Port 80</address> </body></html>

Also APACHE log informs:

php-apache | 172.18.0.1 - - [13/Mar/2023:18:33:57 +0000] "GET /index.php HTTP/1.1" 400 484 "-" "OpenSCADA v0.9.5"

with error 400.

It seems that library is doing a bad request or that the request is not compatible with modern apache web servers.
If I try to connect using browser I get the correct answer and apeche log shows:

php-apache | 172.18.0.1 - - [13/Mar/2023:18:37:16 +0000] "GET /cliente/alarme.php HTTP/1.1" 200 245 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0"



On the other way, if I try to connect to the internal OpenScada Web server (port 10002) I get the correct answer, that is the simple WEB interface HTML code.

Can OpenScada connect to Apache Server and get info from APIs?
IS there some error in OpenScada HTTP library?

Written on: 13. 03. 2023 [20:56]
roman
Roman Savochenko
Moderator
Contributor
Developer
registered since: 12.12.2007
Posts: 3750
There is no problem with Apache and for oscada.org I have got a normal response by the pointed code:

HTML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en-us" lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 
	This website is powered by TYPO3 - inspiring people to share!
	TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
	TYPO3 is copyright 1998-2012 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
	Information and contribution at http://typo3.org/
-->
 
<base href="http://oscada.org/" />
 
<title>OpenSCADA: Main</title>
<meta name="generator" content="TYPO3 4.5 CMS" />
 
<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_4b924f4901.css?1452463808" media="all" />
<link rel="stylesheet" type="text/css" href="typo3/sysext/cms/tslib/media/scripts/defaultstylesheet.css?1424553355" media="all" />
<link rel="stylesheet" type="text/css" href="typo3conf/ext/mm_forum/res/tmpl/default/css/mm_forum.css?1531294920" media="all" />
<link rel="stylesheet" type="text/css" href="fileadmin/template/oscada/res/news.css?1318579419" media="all" />
<link rel="stylesheet" type="text/css" href="fileadmin/template/oscada/rte/dynamiccss.css?1303631616" media="all" />
 
...
 
//document.getElementById("GoogleS").style.background = "";
</script>
 
</body>
</html>



The same in the IO Log:
[2023-03-13T20:53:29.023326] > Sent
GET /index.php HTTP/1.1
Host: oscada.org:80
User-Agent: OpenSCADA v1+r0000



[2023-03-13T20:53:29.490534] < Received
HTTP/1.1 200 OK
Date: Mon, 13 Mar 2023 18:53:29 GMT
Server: Apache/2.2.22 (Debian)
X-Powered-By: PHP/5.4.45-0+deb7u2
Set-Cookie: fe_typo_user=870319d8a12caa02bd255faf8cfd64e0; path=/
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html;charset=utf-8

...

Learn, learn and learn better than work, work and work.
Written on: 13. 03. 2023 [21:53]
diegoeck
Diego Eckhard
Developer
Topic creator
registered since: 25.02.2022
Posts: 5
It seems it only works with some websites (very simple), and that not full specification was implemented.

I can open oscada.org site but I can't open www.google.com:80/ neither my webiste: www.catfish.eng.br:80/.

Could you open catfish or google websites?

Regards,

Diego
Written on: 13. 03. 2023 [22:05]
diegoeck
Diego Eckhard
Developer
Topic creator
registered since: 25.02.2022
Posts: 5
Also, what I get form oscada.org website is:

HTML
<html><body><h1>It works!</h1> <p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p> </body>
</html>


It seems to be default Apache page, and not oscada.org oficial page, as you get.
Written on: 14. 03. 2023 [07:42]
roman
Roman Savochenko
Moderator
Contributor
Developer
registered since: 12.12.2007
Posts: 3750
"diegoeck" wrote:

It seems it only works with some websites (very simple), and that not full specification was implemented.

I can open oscada.org site but I can't open www.google.com:80/ neither my webiste: www.catfish.eng.br:80/.

Google and www.catfish.eng.br are not HTTP, but HTTPS!!!

So, use the SSL transport instead Sockets obviously!

JAVASCRIPT
req=SYS.XMLNode("GET");
req.setAttr("URI","/");
SYS.Transport.outAt("SSL.testHTTP:catfish.eng.br:443").messIO(req,"HTTP");
rez=req.text();



HTML
<!doctype html>
<html lang="pt">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
    <meta name="generator" content="Hugo 0.88.1">
    <title>Catfish Engenharia</title>
 
    <link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/starter-template/">
 
 
 
...
 
 
 
      </footer>
 
 
 
    </div>
    <script src="js/bootstrap.bundle.min.js"></script>
 
  </body>
</html>




[2023-03-14T07:49:11.454765] > Sent
GET / HTTP/1.1
Host: catfish.eng.br:443
User-Agent: OpenSCADA v1+r0000


[2023-03-14T07:49:11.722844] < Received
HTTP/1.1 200 OK
Date: Tue, 14 Mar 2023 05:49:11 GMT
Server: Apache
Last-Modified: Mon, 22 Aug 2022 12:24:38 GMT
ETag: "8c7c11-71df-5e6d3880e3e28"
Accept-Ranges: bytes
Content-Length: 29151
Connection: close
Content-Type: text/html

<!doctype html>
<html lang="pt">
...


Learn, learn and learn better than work, work and work.
Written on: 14. 03. 2023 [14:32]
diegoeck
Diego Eckhard
Developer
Topic creator
registered since: 25.02.2022
Posts: 5
FIXED!

Even with HTTP websites i was getting errors.

I just realize that if I use the address "TCP:oscada.org:80" it works, but if I just use "oscada.org:80" it do not.

Shouldn't i get the same result?

Anyway, it is now working.

Thanks Roman!



5609