Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/slow config editor #428

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading