curl: (7) Failed to connect

OP #6466613
Lesenswert?

Hallo

Ich verwende Buildroot als Distribution auf meinem STM32MP1. Ein Kollege 
hat einen Endpunkt erstellt, um zu testen, ob die MPU eine Verbindung 
zum Server herstellt:

wenn ich:
1
curl -i -k -X POST -H "Content-Type: application/json" https://........

bekomme ich
1
curl: (7) Failed to connect to dv7knsjzph.execute-api.eu-central-1.amazonaws.com port 80: Connection refused


Hat jemand ne Idee warum ich sowas bekomme?

LG
Gast #6466640
Lesenswert?

Mehdi J. schrieb:
> curl: (7) Failed to connect to
> dv7knsjzph.execute-api.eu-central-1.amazonaws.com port 80: Connection
> refused

Weil irgendwas auf der Übertragungsstrecke die Verbindung ablehnt. Was 
das ist, musst du mit geeigneten Netzwerktools ermitteln. Ein erster 
Hinweis könnte sein das Https normalerweise Port 443 nutzt, deine 
Meldung aber sagt aber Port 80. (http ohne S!) refused wird.

Entweder dein Curl Request passt nicht zur Fehlermeldung oder da ist 
irgendwas dazwischen (Router, Firewall, Proxy) das ein redirect 
vornimmt. Außerdem Sieht dein POST Request Komisch aus, ich sehe keine 
Payload, hast du da vielleicht was vergessen zu hier zu Posten Payload 
und oder Port zum Beispiel. Vielleicht ist es auch nicht schlecht erst 
mal ein GET oder HEAD Request zu senden wenn das vom Server Akzeptiert 
wird um das zu debuggen.

ein an geeigneter Stelle, oder ein Debugglog helfen dir sicher auch.


Mehdi J. schrieb:
> Ein Kollege
> hat einen Ruhepunkt erstellt

Was soll denn das bitte sein? mir ist der Begriff im Rahmen von 
Client/Server Kommunikation kein Begriff.
OP #6466663
Lesenswert?

Hi

Habe den "s" in http vergessen .... es ist jetzt besser aber ich bekomme 
folgendes.


HTTP/1.1 502 Bad Gateway
Date: Fri, 06 Nov 2020 13:53:32 GMT
Content-Type: application/json
Content-Length: 36
Connection: keep-alive
x-amzn-RequestId: cadb391e-01e5-4353-97d5-e5a288790a83
x-amzn-ErrorType: InternalServerErrorException
x-amz-apigw-id: VlpGhFIVliAFrUQ=
OP #6466668
Lesenswert?

Sorry ich meinte Endpuntk (RuhePunkt .. was für ein dummes Wort habe ich 
geschrieben).

Wie vorgeschlagen habe ich https verwendet

Läuft besser aber nicht optimal.
Ich bekomme Folgendes:


HTTP/1.1 502 Bad Gateway
Date: Fri, 06 Nov 2020 13:53:32 GMT
Content-Type: application/json
Content-Length: 36
Connection: keep-alive
x-amzn-RequestId: cadb391e-01e5-4353-97d5-e5a288790a83
x-amzn-ErrorType: InternalServerErrorException
x-amz-apigw-id: VlpGhFIVliAFrUQ=
OP #6466701
Lesenswert?

Unter PC meinte ich meinen Laptop.

Ich habe erst Ubuntu LTS verwenden, den curl Befehl benutzt und alles 
hat dann funktioniert

Jetzt mit dem MPU klappt etwas nicht.

Immer eine Gateway Fehlermeldung: HTTP/1.1 502 Bad Gateway

Wieso passiert das mit dem MPU und nicht mit dem PC? Liegt den Fehler 
bei manche Linux Details wo man durch nano etwas ändern muss. Und hat 
meinen Kollege die Konfiguration falsch gemacht.
#6466732
Lesenswert?

Rolf M. schrieb:
> Wenn das mit dem PC nicht auftritt, ist an deiner Anfrage mit dem
> anderen System irgendwas, womit der Server nicht klar kommt.

Klar. Aber wenn der Server die CLients nicht per IP-Adresse 
unterscheidet, muss es ja noch einen anderen Unterschied zwischen den 
Clients geben. Das sieht man vielleicht mit -v oder --trace. Denkbar 
wäre auch ein sich anders verhaltenden TLS seitens des Clients.
OP #6466745
Lesenswert?

(prx) A. K. schrieb:
> 🐧 DPA 🐧 schrieb:
>> Leider ist ja anscheinend TLS involviert, da wird das nicht viel
>> Aufschluss bringen...
>
> Deshalb wäre es hilfreich, den Server vorläufig auch HTTP akzeptieren zu
> lassen, ohne gleich auf HTTPS weiterzuleiten.
>
> Auch curl kann man per -v und --trace geschwätziger machen.

1
# curl -i -v -k -X POST -H "Content-Type: application/json" https://dv7knsjzph.execute-api.eu-central-1.amazonaws.com/prod/boxtronic
2
-devices/2/data/
3
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
4
* TLSv1.3 (IN), TLS handshake, Server hello (2):
5
* TLSv1.2 (IN), TLS handshake, Certificate (11):
6
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
7
* TLSv1.2 (IN), TLS handshake, Server finished (14):
8
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
9
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
10
* TLSv1.2 (OUT), TLS handshake, Finished (20):
11
* TLSv1.2 (IN), TLS handshake, Finished (20):
12
> POST /prod/boxtronic-devices/2/data/ HTTP/1.1
13
> Host: dv7knsjzph.execute-api.eu-central-1.amazonaws.com
14
> User-Agent: curl/7.64.1
15
> Accept: */*
16
> Content-Type: application/json
17
>
18
< HTTP/1.1 502 Bad Gateway
19
HTTP/1.1 502 Bad Gateway
20
< Date: Fri, 06 Nov 2020 14:54:43 GMT
21
Date: Fri, 06 Nov 2020 14:54:43 GMT
22
< Content-Type: application/json
23
Content-Type: application/json
24
< Content-Length: 36
25
Content-Length: 36
26
< Connection: keep-alive
27
Connection: keep-alive
28
< x-amzn-RequestId: 14268351-e6d6-4c51-9d5f-1496b0ebfb0d
29
x-amzn-RequestId: 14268351-e6d6-4c51-9d5f-1496b0ebfb0d
30
< x-amzn-ErrorType: InternalServerErrorException
31
x-amzn-ErrorType: InternalServerErrorException
32
< x-amz-apigw-id: VlyEAF6GliAFvHg=
33
x-amz-apigw-id: VlyEAF6GliAFvHg=
34

35
<
36
{"message": "Internal server error"}#
OP #6466773
Lesenswert?

(prx) A. K. schrieb:
> Und das nun mit der exakt gleichen Operation beim PC vergleichen.
> Ebenso mit --trace.

Curl STM
1
# curl -i -k -v -X --trace POST -H "Content-Type: application/json" https://dv7knsjzph.execute-api.eu-central-1.amazonaws.com/prod/b
2
oxtronic-devices/2/data/
3
* Could not resolve: POST (DNS server returned answer with no data)
4
curl: (6) Could not resolve: POST (DNS server returned answer with no data)
5
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
6
* TLSv1.3 (IN), TLS handshake, Server hello (2):
7
* TLSv1.2 (IN), TLS handshake, Certificate (11):
8
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
9
* TLSv1.2 (IN), TLS handshake, Server finished (14):
10
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
11
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
12
* TLSv1.2 (OUT), TLS handshake, Finished (20):
13
* TLSv1.2 (IN), TLS handshake, Finished (20):
14
> --trace /prod/boxtronic-devices/2/data/ HTTP/1.1
15
> Host: dv7knsjzph.execute-api.eu-central-1.amazonaws.com
16
> User-Agent: curl/7.64.1
17
> Accept: */*
18
> Content-Type: application/json
19
>
20
< HTTP/1.1 400 Bad Request
21
HTTP/1.1 400 Bad Request
22
< Server: awselb/2.0
23
Server: awselb/2.0
24
< Date: Fri, 06 Nov 2020 15:08:39 GMT
25
Date: Fri, 06 Nov 2020 15:08:39 GMT
26
< Content-Type: text/html
27
Content-Type: text/html
28
< Content-Length: 122
29
Content-Length: 122
30
< Connection: close
31
Connection: close
32

33
<
34
<html>
35
<head><title>400 Bad Request</title></head>
36
<body>
37
<center><h1>400 Bad Request</h1></center>
38
</body>
39
</html>
40
* TLSv1.2 (OUT), TLS alert, close notify (256):


Curl Laptop
1
* Rebuilt URL to: POST/
2
* Could not resolve host: POST
3
* Closing connection 0
4
curl: (6) Could not resolve host: POST
5
*   Trying 3.123.217.92...
6
* TCP_NODELAY set
7
* Connected to dv7knsjzph.execute-api.eu-central-1.amazonaws.com (3.123.217.92) port 443 (#1)
8
* ALPN, offering h2
9
* ALPN, offering http/1.1
10
* successfully set certificate verify locations:
11
*   CAfile: /etc/ssl/certs/ca-certificates.crt
12
  CApath: /etc/ssl/certs
13
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
14
* TLSv1.3 (IN), TLS handshake, Server hello (2):
15
* TLSv1.2 (IN), TLS handshake, Certificate (11):
16
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
17
* TLSv1.2 (IN), TLS handshake, Server finished (14):
18
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
19
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
20
* TLSv1.2 (OUT), TLS handshake, Finished (20):
21
* TLSv1.2 (IN), TLS handshake, Finished (20):
22
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
23
* ALPN, server accepted to use h2
24
* Server certificate:
25
*  subject: CN=*.execute-api.eu-central-1.amazonaws.com
26
*  start date: Aug 29 00:00:00 2020 GMT
27
*  expire date: Sep 29 12:00:00 2021 GMT
28
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
29
*  SSL certificate verify ok.
30
* Using HTTP2, server supports multi-use
31
* Connection state changed (HTTP/2 confirmed)
32
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
33
* Using Stream ID: 1 (easy handle 0x55aa08f85580)
34
> --trace /prod/boxtronic-devices/3/data/ HTTP/2
35
> Host: dv7knsjzph.execute-api.eu-central-1.amazonaws.com
36
> User-Agent: curl/7.58.0
37
> Accept: */*
38
> Content-Type: application/json
39
>
40
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
41
< HTTP/2 400
42
HTTP/2 400
43
< server: awselb/2.0
44
server: awselb/2.0
45
< date: Fri, 06 Nov 2020 15:10:52 GMT
46
date: Fri, 06 Nov 2020 15:10:52 GMT
47
< content-type: text/html
48
content-type: text/html
49
< content-length: 122
50
content-length: 122
51

52
<
53
<html>
54
<head><title>400 Bad Request</title></head>
55
<body>
56
<center><h1>400 Bad Request</h1></center>
57
</body>
58
</html>
59
* Connection #1 to host dv7knsjzph.execute-api.eu-central-1.amazonaws.com left intact
Gast #6466777
Lesenswert?

1
daniel@mamut:~$ nslookup dv7knsjzph.execute-api.eu-central-1.amazonaws.com
2
Server:    10.60.10.2
3
Address:  10.60.10.2#53
4

5
Non-authoritative answer:
6
Name:  dv7knsjzph.execute-api.eu-central-1.amazonaws.com
7
Address: 35.157.166.90
8
Name:  dv7knsjzph.execute-api.eu-central-1.amazonaws.com
9
Address: 18.158.83.7

DNS Round Robin. Eventuell hat ein Client die eine IP gecached, und der 
andere die andere. Wenn dann eine davon nicht geht, würde dass das 
erklären. versuch mal die beiden IPs direkt, statt der Domain.
Beitrag #6466780 wurde von einem Moderator gelöscht.
Gast #6466793
Lesenswert?

Mehdi J. schrieb:
> Immer eine Gateway Fehlermeldung: HTTP/1.1 502 Bad Gateway


Laut wikipedia:

502   Bad Gateway   Der Server konnte seine Funktion als Gateway oder 
Proxy nicht erfüllen, weil er seinerseits eine ungültige Antwort 
erhalten hat.

kann es sein das deine Payload (-d) im Curl falsch/unverständlich etc 
ist?
OP #6466812
Lesenswert?

(prx) A. K. schrieb:
> Imonbln schrieb:
>> kann es sein das deine Payload (-d) im Curl falsch/unverständlich etc
>> ist?
>
> In seinem Kommando steht keine Payload drin. ;-)
>
> Ich will mal hoffen, dass bei seinem erfolgreichen Test mit Ubuntu auch
> keine drin stand, sonst ist das evtl der Fehler. Wenn ich das von Linux
> aus absende, gibts ebenfalls den 502.


Ich mache es wieder


--> Laptop
1
curl -i -k -v -X --trace POST -H "Content-Type: application/json" https://18.158.83.7/prod/boxtronic-devices/2/data/
2
* Rebuilt URL to: POST/
3
* Could not resolve host: POST
4
* Closing connection 0
5
curl: (6) Could not resolve host: POST
6
*   Trying 18.158.83.7...
7
* TCP_NODELAY set
8
* Connected to 18.158.83.7 (18.158.83.7) port 443 (#1)
9
* ALPN, offering h2
10
* ALPN, offering http/1.1
11
* successfully set certificate verify locations:
12
*   CAfile: /etc/ssl/certs/ca-certificates.crt
13
  CApath: /etc/ssl/certs
14
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
15
* TLSv1.3 (IN), TLS handshake, Server hello (2):
16
* TLSv1.2 (IN), TLS handshake, Certificate (11):
17
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
18
* TLSv1.2 (IN), TLS handshake, Server finished (14):
19
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
20
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
21
* TLSv1.2 (OUT), TLS handshake, Finished (20):
22
* TLSv1.2 (IN), TLS handshake, Finished (20):
23
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
24
* ALPN, server accepted to use h2
25
* Server certificate:
26
*  subject: CN=*.execute-api.eu-central-1.amazonaws.com
27
*  start date: Aug 29 00:00:00 2020 GMT
28
*  expire date: Sep 29 12:00:00 2021 GMT
29
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
30
*  SSL certificate verify ok.
31
* Using HTTP2, server supports multi-use
32
* Connection state changed (HTTP/2 confirmed)
33
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
34
* Using Stream ID: 1 (easy handle 0x55df1a16b580)
35
> --trace /prod/boxtronic-devices/2/data/ HTTP/2
36
> Host: 18.158.83.7
37
> User-Agent: curl/7.58.0
38
> Accept: */*
39
> Content-Type: application/json
40
>
41
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
42
< HTTP/2 400
43
HTTP/2 400
44
< server: awselb/2.0
45
server: awselb/2.0
46
< date: Fri, 06 Nov 2020 15:42:20 GMT
47
date: Fri, 06 Nov 2020 15:42:20 GMT
48
< content-type: text/html
49
content-type: text/html
50
< content-length: 122
51
content-length: 122
52

53
<
54
<html>
55
<head><title>400 Bad Request</title></head>
56
<body>
57
<center><h1>400 Bad Request</h1></center>
58
</body>
59
</html>
60
* Connection #1 to host 18.158.83.7 left intact



                                  --> STM32MP1
1
curl -i -k -v -X --trace POST -H "Content-Type: application/json" https://18.158.83.7/prod/boxtronic-devices/2/data/
2
* Could not resolve: POST (DNS server returned answer with no data)
3
curl: (6) Could not resolve: POST (DNS server returned answer with no data)
4
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
5
* TLSv1.3 (IN), TLS handshake, Server hello (2):
6
* TLSv1.2 (IN), TLS handshake, Certificate (11):
7
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
8
* TLSv1.2 (IN), TLS handshake, Server finished (14):
9
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
10
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
11
* TLSv1.2 (OUT), TLS handshake, Finished (20):
12
* TLSv1.2 (IN), TLS handshake, Finished (20):
13
> --trace /prod/boxtronic-devices/2/data/ HTTP/1.1
14
> Host: 18.158.83.7
15
> User-Agent: curl/7.64.1
16
> Accept: */*
17
> Content-Type: application/json
18
>
19
< HTTP/1.1 400 Bad Request
20
HTTP/1.1 400 Bad Request
21
< Server: awselb/2.0
22
Server: awselb/2.0
23
< Date: Fri, 06 Nov 2020 15:43:23 GMT
24
Date: Fri, 06 Nov 2020 15:43:23 GMT
25
< Content-Type: text/html
26
Content-Type: text/html
27
< Content-Length: 122
28
Content-Length: 122
29
< Connection: close
30
Connection: close
31

32
<
33
<html>
34
<head><title>400 Bad Request</title></head>
35
<body>
36
<center><h1>400 Bad Request</h1></center>
37
</body>
38
</html>
39
* TLSv1.2 (OUT), TLS alert, close notify (256):
Gast #6466831
Lesenswert?

Mehdi J. schrieb:
> Ich mache es wieder
>
> --> Laptop
> curl -i -k -v -X --trace POST -H "Content-Type: application/json"
> https://18.158.83.7

Mehdi J. schrieb:
> curl -i -k -v -X --trace POST -H "Content-Type: application/json"
> https://18.158.83.7/prod/boxtronic-devices/2/data/

Und wieder Falsch "-X POST --trace" der parameter -X braucht ein 
Argument.

"-X --trace POST " ist falsch we du am response sehen kannst!
OP #6466838
Lesenswert?

Imonbln schrieb:
> Mehdi J. schrieb:
>> Ich mache es wieder
>>
>> --> Laptop
>> curl -i -k -v -X --trace POST -H "Content-Type: application/json"
>> https://18.158.83.7
>
> Mehdi J. schrieb:
>> curl -i -k -v -X --trace POST -H "Content-Type: application/json"
>> https://18.158.83.7/prod/boxtronic-devices/2/data/
>
> Und wieder Falsch "-X POST --trace" der parameter -X braucht ein
> Argument.
>
> "-X --trace POST " ist falsch we du am response sehen kannst!


So ?
1
curl -i -k -v -X POST --trace -H "Content-Type: application/json"
2
https://18.158.83.7
Gast #6466842
Lesenswert?

Mehdi J. schrieb:
> curl -i -k -v -X POST --trace -H "Content-Type: application/json"
> https://18.158.83.7

Ja schon eher, ich würde aber den Webserver mit Namen ansprechen und 
nicht mit der IP, da er ansonsten vielleicht nicht weiß für welche 
seiner Instanzen der Request ist.

also so:
1
 
2
curl -i -k -v -X POST --trace -H "Content-Type: application/json" https://dv7knsjzph.execute-api.eu-central-1.amazonaws.com/prod/b
OP #6466845
Lesenswert?

Imonbln schrieb:
> Mehdi J. schrieb:
>> curl -i -k -v -X POST --trace -H "Content-Type: application/json"
>> https://18.158.83.7
>
> Ja schon eher, ich würde aber den Webserver mit Namen ansprechen und
> nicht mit der IP, da er ansonsten vielleicht nicht weiß für welche
> seiner Instanzen der Request ist.
>
> also so:
>
>
1
> curl -i -k -v -X POST --trace -H "Content-Type: application/json" 
2
> https://dv7knsjzph.execute-api.eu-central-1.amazonaws.com/prod/b
3
>


Dann bekomme ich so (Laptop). Fehlermeldung

Warning: --trace overrides an earlier trace/verbose option
curl: (3) Port number ended with ' '
HTTP/2 502
date: Fri, 06 Nov 2020 16:11:08 GMT
content-type: application/json
content-length: 36
x-amzn-requestid: f6c48639-85f3-4dd2-b3d0-add483c93d63
x-amzn-errortype: InternalServerErrorException
x-amz-apigw-id: Vl9QaGqgliAFcww=

{"message": "Internal server error"}
Gast #6466854
Lesenswert?

Mehdi J. schrieb:
> Dann bekomme ich so (Laptop). Fehlermeldung
>
> Warning: --trace overrides an earlier trace/verbose option
> curl: (3) Port number ended with ' '
> HTTP/2 403
> date: Fri, 06 Nov 2020 16:07:18 GMT
> content-type: application/json
> content-length: 42
> x-amzn-requestid: 65b0694d-5b39-4e03-968d-746050b59cf6
> x-amzn-errortype: MissingAuthenticationTokenException
> x-amz-apigw-id: Vl8sdFDYliAFW-w={"message":"Missing Authentication
> Token"}m

Na das ist doch mal ein Fortschritt jetzt hast du ein 403, weil dein 
Request kein Authentication Token hat. frage mal dein Kollegen wie du so 
ein Token bekommen kannst ;) Vermutlich musst du denn irgendwo bei AWS 
abholen und mit in dein Curl request Packen ( vermutlich in den HEADER 
des Request)
#6466980
Lesenswert?

Mehdi J. schrieb:
> Warning: --trace overrides an earlier trace/verbose option
> curl: (3) Port number ended with ' '

Du, es wäre schon schlau wenn du Fehlermeldungen auch beachtest und mal 
fünf Minuten auf die Man-Page von curl schaust um die richtigen Optionen 
und Syntax zu finden.

Du behauptest hier seit Stunden dass das gleiche Kommando von einem 
Rechner geht, vom anderen nicht. Dabei sind es immer unterschiedliche 
Kommandos die du hier zeigst.
OP #6467509
Lesenswert?

Imonbln schrieb:
> Mehdi J. schrieb:
>> Dann bekomme ich so (Laptop). Fehlermeldung
>>
>> Warning: --trace overrides an earlier trace/verbose option
>> curl: (3) Port number ended with ' '
>> HTTP/2 403
>> date: Fri, 06 Nov 2020 16:07:18 GMT
>> content-type: application/json
>> content-length: 42
>> x-amzn-requestid: 65b0694d-5b39-4e03-968d-746050b59cf6
>> x-amzn-errortype: MissingAuthenticationTokenException
>> x-amz-apigw-id: Vl8sdFDYliAFW-w={"message":"Missing Authentication
>> Token"}m
>
> Na das ist doch mal ein Fortschritt jetzt hast du ein 403, weil dein
> Request kein Authentication Token hat. frage mal dein Kollegen wie du so
> ein Token bekommen kannst ;) Vermutlich musst du denn irgendwo bei AWS
> abholen und mit in dein Curl request Packen ( vermutlich in den HEADER
> des Request)

Musste nur was im Body geändert werden ..

curl -i -k -X POST -H "Content-Type: application/json" --data '{ 
"id":"id","timestamp":"data","data":"data"}' 
https://dv7knsjzph.execute-api.eu-central-1.amazonaws.com/prod/boxtronic-devices/2/data/

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren