Comments (8)
I fixed this in my fork awhile ago, sorry for being vague since i dont completely remember, but the best i could gather when i looked into it was that the conn reset was a windows only thing. Hope it helps.
/// <summary>
/// Done to prevent exceptions in Socket.BeginReceive()
/// May only be an issue on windows.
/// </summary>
/// <remarks>
/// http://microsoft.public.win32.programmer.networks.narkive.com/RlxW2V6m/udp-comms-and-connection-reset-problem
/// https://stackoverflow.com/questions/34242622/windows-udp-sockets-recvfrom-fails-with-error-10054
/// https://stackoverflow.com/questions/38790802/determine-operating-system-in-net-core
/// </remarks>
private static void DisableConnReset(UdpClient client)
{
if (EnvironmentHelper.IsWindowsEnvironment())
{
const uint IOC_IN = 0x80000000;
const uint IOC_VENDOR = 0x18000000;
const uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
client?.Client.IOControl(unchecked((int)SIO_UDP_CONNRESET),
new[] { System.Convert.ToByte(false) }, null);
}
}
from bacnet.
Hi BACnet libary team
Please reopen issue and integrate fix for DisableConnReset to v2-netstandard branch.
I'm using .net core 3.1. Library working fine on windows 10 + wsl2 + docker and on raspberry pi 4 + ubuntu + docker.
IsOSPlatform is supported by .net core, .net framework, .net standard
https://docs.microsoft.com/en-US/dotnet/api/system.runtime.interopservices.runtimeinformation.isosplatform?view=netcore-3.1
private static void DisableConnReset(UdpClient client)
{
bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
if (isWindows)
{
const uint IOC_IN = 0x80000000;
const uint IOC_VENDOR = 0x18000000;
const uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
client?.Client.IOControl(unchecked((int)SIO_UDP_CONNRESET),
new[] { System.Convert.ToByte(false) }, null);
}
}
from bacnet.
I'm getting the same exception with the same calls as hoangdungt2 on a OSX and Linux Debian. I'm using an ARM processor. The error seems to stem from the following line in the BACnet.dll
client?.Client.IOControl(unchecked((int)SIO_UDP_CONNRESET),
new[] { System.Convert.ToByte(false) }, null);
from bacnet.
Hi @minzdrav, you are right this should be integrated with that branch. I will let you know when this is available.
from bacnet.
for my case, it works just fine, when you create bacnet client do not enter ip address in there
var bacnetClient = new BacnetClient(new BacnetIpUdpProtocolTransport(0xBAC0, false));
bacnetClient.start();
I don't use mono, just publish as "linux-arm" and it will work well for rp3, e.g.
dotnet publish -c Release -r linux-arm -o outputFolder
from bacnet.
I made the following change to BacnetIpUdpProtocolTransport.cs file of the v2-netstandard branch
line 85
if (_dontFragment) _sharedConn.DontFragment = _dontFragment;
removed line 105
added line 107
if (_dontFragment) _exclusiveConn.DontFragment = _dontFragment;
changed line 139 to
try
{
client?.Client.IOControl(unchecked((int)SIO_UDP_CONNRESET),
new[] { System.Convert.ToByte(false) }, null);
}
catch (PlatformNotSupportedException ex)
{
var socket = new Socket(client.Client.AddressFamily, client.Client.SocketType, client.Client.ProtocolType);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
}
Note: This will only work if you call BacnetIpUdpProtocolTransport() with dontFragment=false. I don't know much about socket programming but I assume that disabling connection reset is the same as keeping the connection alive.
from bacnet.
The solution provided by @mykah89 and @pnguyen-ecs worked for me and no errors appeared.
Many thanks everybody.🙏
from bacnet.
Any idea when this change will be available?
from bacnet.
Related Issues (20)
- problem with 'shared port' in bacnet ip/udp module HOT 1
- OutOfRangeException when sending big request HOT 3
- Setting up a notification class
- Trouble Publishing Due to Out-Of-Date Dependencies HOT 1
- Throws exception when parsing 'BacnetAddress' structure with broadcast mac address HOT 1
- IndexOutOfRangeException when calling BacnetClient.ReadPropertyResponse
- Setting `.DontFragment` on `UdpClient` on MacOS fails with an exception HOT 1
- SEGMENTATION NOT SUPPORTED WHEN REQUESTING DEVICE WITH MANY OBJECT PROPERTIES HOT 5
- Secure Bacnet (BACnetSC)
- BasicReadAndWrite Example got Nullreference exception when reading Analog input HOT 1
- Is it Possible to Create a BACnet/IP to BACnet/MSTP Router using This Library?
- VS2022 Compile issues with BasicReadWrite Example
- YABE compatibility
- ExceptionSchedule Property - Write
- Notification Class not receiving all notifications in .Net 6.0 Windows/Linux
- Problem in Discovering devices in a network from docker container running in Ubuntu 18 HOT 2
- Decode error when reading PROP_ACTIVE_COV_SUBSCRIPTIONS HOT 2
- False negative address comparison for some BACnet Devices HOT 1
- Error on notification class reception
- Failed to read property PROP_OBJECT_LIST
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bacnet.