Beckhoff HTTPS Problem

Itrim

Member
Join Date
Apr 2017
Location
Scotland
Posts
22
Hi,

I'm trying to connect to server to send some data and I'm having problem with HTTPS connection, specifically with TLS set-up. I'm getting HTTP_REQ_CONN_TIMEDOUT on FB_IotHttpRequest function block.

According to my server provider I'm using valid certificates and port.

I can ping the server from IPC and plain HTTP works fine.

The code is very simple and done according to the sample.

I wrote to Beckhoff support too, but they are yet to answer.

This is my first time working with HTTPS and cloud services.

Below th code. As you can see there is not much I can change there.

Code:
VAR
	IoThttpCLIENT: FB_iothttpclient := (sHostName := 'deleted',
 										bKeepAlive := FALSE,
 										tConnectionTimeout := T#10S);
		Connect: BOOL;
		Connect_TOF: TOF;
	
	Post: fbJsonPost;
		Send: BOOL;
		Keep: BOOL;
		Busy: BOOL;
		Error: BOOL;
Code:
IF NOT IoThttpCLIENT.bConfigured THEN
	IoThttpCLIENT.stTLS.sCA := 'C:\Users\GriegLSI001\Crt\fullchain1.pem';
	IoThttpCLIENT.stTLS.sCert := 'C:\Users\GriegLSI001\Crt\cert1.pem';
	IoThttpCLIENT.stTLS.sKeyFile := 'C:\Users\GriegLSI001\Crt\privkey1.pem';
	IoThttpCLIENT.nHostPort := 443;
END_IF


IF Connect THEN
	IoThttpCLIENT.Execute();
ELSE
	IoThttpCLIENT.Disconnect();
END_IF

IF IoThttpCLIENT.bConfigured THEN	
	Post(bSend:=Send, fbClient:=IoThttpCLIENT, bBusy => Busy, bError => Error, bKeepSending := Keep);
END_IF


Code:
FUNCTION_BLOCK fbJsonPost
VAR_INPUT
	bSend: BOOL;
	bKeepSending: BOOL;
END_VAR
VAR_OUTPUT
	bBusy: BOOL;
	bError: BOOL;
END_VAR
VAR
	R_TRIG: R_TRIG;
	sContent: SJsonValue;
	sContent_2: STRING(511);
	nState: USINT;
	RN: DRAND;
	JsonDomParser: FB_JsonDomParser;
	JsonWriter: FB_JsonSaxWriter;
	fbRequest: FB_IotHttpRequest;
	header: FB_IotHttpHeaderFieldMap;
	
	TON: TON;
	test: BOOL;
END_VAR
VAR_IN_OUT
	fbClient: FB_IotHttpClient;
END_VAR
Code:
CASE nState OF
	0: 	R_TRIG(CLK := bSend);

		IF R_TRIG.Q OR bKeepSending THEN
			sContent := JsonDomParser.NewDocument();
			JsonDomParser.AddStringMember(sContent, 'key', 'sensor');
			JsonDomParser.AddIntMember(sContent, 'value', DINT_TO_UDINT(fbClient.nMessagesSent));
			sContent_2 := JsonDomParser.GetDocument();
			
			nState := 1;
		END_IF

	1:	fbRequest.SendJsonDomRequest(sUri:= '', fbClient:= fbClient,
								eRequestType := ETcIotHttpRequestType.HTTP_POST,
								fbJson := JsonDomParser, fbHeader := header);
								
		nState := 2;
	
	2: 	IF NOT fbRequest.bBusy THEN
			nState := 0;
			test := TRUE;
			JsonDomParser.RemoveAllMembers(sContent);
		END_IF
END_CASE

bBusy := fbRequest.bBusy;
 
Are you sure that you're using the correct cert? I just finished a project using HTTPS, and I used the Base64 cert type. Maybe try that? Also, make sure that you are using the correct port, and that the firewall isn't blocking anything.
 
In my experience with security, the certificates are always wrong the first time you set it up, no matter what. Doesn't matter if you're following the official step by step guide, it's ALWAYS the certificates. Somehow.
 
I also remembered something that I think might solve your issue. Make sure you are cyclically calling the fbRequest.Execute() method in your program. Call it outside of your case statement.
 

Similar Topics

I'm trying to integrate a Beckhoff IPC with a Controllogix PLC. There is some documentation, on the Beckhoff website, on how to do a PLC-PLC comms...
Replies
0
Views
64
Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
1,047
Hello sameone have Beckhoff PLC Siemens Sinamics V90 configuration example?
Replies
0
Views
101
hello, I am using Beckhoff with TwinCAT3 and when I change or add some new hardware or for any reason, there is a mismatch in the real hardware vs...
Replies
1
Views
133
I have a Beckhoff CX7000 IPC with some digital I/O built-in and I additionally need two analog inputs 0-10V. Can I install both Ethernet terminals...
Replies
4
Views
213
Back
Top Bottom