Skip to content

Commit

Permalink
Merge pull request #428 from PHOENIXCONTACT/bugfix/slow-config-editor
Browse files Browse the repository at this point in the history
Bugfix/slow config editor
  • Loading branch information
Toxantron authored May 23, 2024
2 parents 95da27d + 36ca13b commit 5844846
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ export default class ClassEditor extends CollapsibleEntryEditorBase<ClassEditorS
return (
<div>
<Collapse in={this.props.IsExpanded}>
<Container style={{paddingRight: "0"}}>
{this.preRenderConfigEditor()}
</Container>
{
this.props.IsExpanded &&
<Container style={{paddingRight: "0"}}>
{this.preRenderConfigEditor()}
</Container>
}
</Collapse>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class CollectionEditor extends CollapsibleEntryEditorBase<Collect
return (
<Collapse in={this.props.IsExpanded}>
<Grid container={true} item={true} sx={{paddingLeft: 3, paddingRight: 0}}>
{
{ this.props.IsExpanded &&
this.props.Entry.subEntries.map((entry, idx) => {
if (Entry.isClassOrCollection(entry)) {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/Moryx/Communication/Sockets/Client/TcpClientConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ internal void Connected()
{
_transmission = new TcpTransmission(_tcpClient, _validator.Interpreter, Logger.GetChild(string.Empty, typeof(TcpTransmission)));
_transmission.Disconnected += ConnectionClosed;
_transmission.ExceptionOccured += OnTransmissionException;
_transmission.ExceptionOccurred += OnTransmissionException;
_transmission.Received += MessageReceived;
_transmission.StartReading();

Expand Down Expand Up @@ -205,7 +205,7 @@ internal void Disconnect()

// First close the connection and then unregister events
transmission.Disconnect();
transmission.ExceptionOccured -= OnTransmissionException;
transmission.ExceptionOccurred -= OnTransmissionException;
transmission.Received -= MessageReceived;
transmission.Disconnected -= ConnectionClosed;

Expand Down
20 changes: 16 additions & 4 deletions src/Moryx/Communication/Sockets/TcpTransmission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class TcpTransmission : IBinaryTransmission, IDisposable
/// <summary>
/// Callback to forward transmission exceptions to connection
/// </summary>
public event EventHandler<Exception> ExceptionOccured;
public event EventHandler<Exception> ExceptionOccurred;

/// <summary>
/// Initialize TcpTransmission
Expand All @@ -53,10 +53,10 @@ public TcpTransmission(TcpClient client, IMessageInterpreter interpreter, ILogge

private void RaiseException(Exception ex)
{
if (ExceptionOccured == null)
if (ExceptionOccurred == null)
_logger.Log(LogLevel.Error, ex, "TcpTransmission encountered an error");
else
ExceptionOccured(this, ex);
ExceptionOccurred(this, ex);
}

private void RaiseDisconnected()
Expand All @@ -81,7 +81,19 @@ public void ConfigureKeepAlive(int interval, int timeout)
// Configure socket using net6 keep alive configuration
socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveInterval, interval);
socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveTime, timeout);
socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveRetryCount, 2);

try
{
// Try to set the TcpKeeepAliveRetryCount, it is not supported on all windows systems
// https://learn.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options#windows-support-for-ipproto_tcp-options
socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveRetryCount, 2);

}
catch(Exception ex)
{
_logger.Log(LogLevel.Warning, ex, "TcpKeepAliveRetryCount could not be applied!");
}

socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
#else
// Keep alive only supported for windows under netstandard2.0
Expand Down

0 comments on commit 5844846

Please sign in to comment.