Comments (9)
proposed fix from link:
Add
public bool IsIPv6Supported { get { return false; } }
replace host.AddressList[0]
with
foreach (IPAddress address in host.AddressList)
{
if ((address.AddressFamily ==
System.Net.Sockets.AddressFamily.InterNetworkV6) &&
!IsIPv6Supported)
continue;
return address;
}
current code NetworkSender.cs
/// <summary>
/// Parses the URI into an endpoint address.
/// </summary>
/// <param name="uri">The URI to parse.</param>
/// <param name="addressFamily">The address family.</param>
/// <returns>Parsed endpoint.</returns>
protected virtual EndPoint ParseEndpointAddress(Uri uri, AddressFamily addressFamily)
{
#if SILVERLIGHT
return new DnsEndPoint(uri.Host, uri.Port, addressFamily);
#else
switch (uri.HostNameType)
{
case UriHostNameType.IPv4:
case UriHostNameType.IPv6:
return new IPEndPoint(IPAddress.Parse(uri.Host), uri.Port);
default:
{
var addresses = Dns.GetHostEntry(uri.Host).AddressList;
foreach (var addr in addresses)
{
if (addr.AddressFamily == addressFamily || addressFamily == AddressFamily.Unspecified)
{
return new IPEndPoint(addr, uri.Port);
}
}
throw new IOException("Cannot resolve '" + uri.Host + "' to an address in '" + addressFamily + "'");
}
}
#endif
}
Not sure if we should use AddressFamily
instead of IsIPv6Supported
from nlog.
@mikhail-barg can you help us in closing this one?
from nlog.
I don't think I have any IPv6 setups within reach, but I'll check tomorrow.
Also I'm not sure what exact configuration is causing the problem. I'm not convenient with IPv6 addressing, but I assume ::1
is a localhost, so both sender and receiver should be on a same machine, or I'm missing something in the original post?
from nlog.
@mikhail-barg Is this something you could test? Testing with ::1
seems OK to me.
from nlog.
I will see if I could check this. I don't have any IPv6 setup at my work, and at home I don't have any network message receivers, so I'll have to write something myself.
from nlog.
@mikhail-barg any change to test this?
Everyone has ::1
(localhost) on his machine?
from nlog.
Sorry, I'm overloaded with work and literally have no free time currently. I'll do what I can when I have some time, but not sure if I could make it in time to get into 4.3
from nlog.
I finally found time to check the issue. The original post does not contain too much info on reproducing the problem (here are working links to original post:
http://nlog-forum.1685105.n2.nabble.com/IPV6-Bug-tt1685313.html#none
https://sourceforge.net/p/nlog/mailman/message/1603760/ )
I assumed that the Network target was used with TCP protocol. And also I decided to not try installing Chainsaw or nlog-viewer, but to write some simple TCP-listener.
Here are the results:
when listening to 127.0.0.1
:
- logging to
tcp://127.0.0.1
-> OK; - logging to
tcp4://localhost
-> OK; - logging to
tcp://localhost
-> fails withSystem.IO.IOException: Error: ConnectionRefused
;
when listening to ::1
:
- logging to
tcp://[::1]
-> OK; - logging to
tcp6://localhost
-> OK; - logging to
tcp://localhost
-> OK;
So the issue happens when listener listens to IPv4, and logger logs to localhost
without explicitly specifying protocol version and system decides to use IPv6 address for it. I'm not sure if this is an original problem though.
I'm also not sure that this problem is related to NLog. If I issue ping localhost
on my machine I get
it resolved to [::1]
as well. Specifying explicit usage of tcp4
solves the problem.
As far as I understand the proposed solution, it just forces using IPv4 in case the protocol is not specified explicitly, so it would just result in a symmetrical problem (logging to localhost
while listening to [::1]
would fail). Considering that IPv6 is "the future", I don't think it's a good idea.
For now I'm attaching the code I've used to test things.
NLogIssue39.zip
from nlog.
Thanks, will close this as we don't have anything to do here.
from nlog.
Related Issues (20)
- Unable to receive email after updating NLog version HOT 5
- NLogViewer target HOT 6
- A severity level between Info and Warning HOT 4
- "Unrecognized value" exception on empty arrays and objects HOT 4
- CallSite extracting caller information from the Exception
- The separator between seconds and milliseconds is culture independent in date and longdate layouts HOT 5
- LoadConfigurationFromAppSettings() in NLog.Extensions.Hosting HOT 5
- AsyncTargetWrapper with OverflowAction=Block halts on ThreadPool starvation HOT 7
- Allow Culture override on LayoutRenderer
- How to avoid loading LoggingConfiguration from app.config HOT 12
- LogFactory should only know ITargetWithFilterChain
- Can't remove [INFO] [Microsoft.EntityFrameworkCore.Database.Command] Executed DbCommand from console logs HOT 3
- No logging output when using LogManager.GetCurrentClassLogger() HOT 4
- File log are deleted when MaxArchiveFiles is less than total number of multiple targets HOT 3
- Set license expression on packages HOT 3
- Add additional TFM to reduce dependencies HOT 7
- Deprecate additional Nuget Packages HOT 4
- Allow for the removal of the inherent callsite information in fluent logs (?) HOT 4
- Unused target detected. Add a rule for this target to the configuration. But a rule does exist in the configuration. HOT 4
- NLog.Database version 5.2.8 with net8 error HOT 8
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 nlog.