Skip to main content
Answer

How does NLog work and why is it returning connection refused?

  • September 29, 2023
  • 6 replies
  • 181 views

Forum|alt.badge.img+1

Hi,

 

I have two local instances of 2022.217.202.5321 hosted on the same PC which have two different customisations.  On one of these instances the debugger behaves perfectly, on the other it doesn’t.

 

On the one that doesn’t behave I was getting lots of missing symbols/can’t load Nlog.pdb, etc. messages.  After doing some research on symbols, I ended up changing the paths in the yellow box below in Visual Studio from tools Options/debugging/symbols.

 

On the instance which is having the problems I currently have:

  1. C:\Users\John\Wrk\Helm\MYOB Versions\MYOB.Advanced-2022.217.202.5231\Files\Bin
  2. C:\Users\John\Wrk\Helm\MYOB Versions\MYOB.Advanced-2022.217.202.5231\Schick_20230929\Bin

I set these to make the unable to load symbols messages I was getting go away.  Have never had to mess with these before and I’m not 100% sure that I am doing the right thing here - but id did resolve the missing symbol problems.

 

On the instance which works fine I have:

  1. c:\users\john\wrk\helm\natt
  2. C:\Users\John\Wrk\Helm\MYOB Versions\Natasha.AdvancedLive.2021.213.202.9403.zip

These settings don’t look right to me but I’m not touching them as this instance behaves itself, 1) above doesn’t exist, and 2) is a reference to a zip file for an older version of Acumatica.

 

In terms of the instance that isn’t working I was also prompted to download a copy of SingleCallContinuation.cs from some web address which I did. This file is now residing on my local machine at  C:\Users\John\AppData\Local\SourceServer\94d69258543da2b1d1048f4806df72ca741c6b554da703cf91ebb7f55df7f7ef\src\NLog\Internal\SingleCallContinuation.cs

Now when my customisation throws an error and Visual studio starts it’s debug process I get the  exception message below:


NLog.NLogRuntimeException
  HResult=0x80131500
  Message=Exception occurred in NLog
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Inner Exception 1:
IOException: Error: ConnectionRefused


 

And, I can put a break in SingleCallContinuation.cs as  shown below which is just before the error message:

 

 

My theory is that there is some kind of setup issue in the instance that is not behaving.

 

Any help on this greatly appreciated,

 

Thanks,

John

 

 

 

 

 

 

Best answer by benb1977

Hi John,

Yes these are exactly the same scenario. The URL I am speaking of is part of an API exposed by a lease management software product, and like any API worth its salt, it is secured with HTTPS. I assume the API you’re connecting to is secured in the same way. Connecting to any URL through HTTPS requires a server certificate validation check, and it looks as though even in the case of a successful check, MYOB Acumatica feels the need to log it, specifically through NLog.

Out of the box, NLog is configured to send all log messages to TCP port 1514 on localhost. When it inevitably discovers that there is nothing listening on this port to accept the request, the I/O completion port throws an exception that is not caught by the application, crashing w3wp.exe and causing no end of profanity on the part of the developer just trying to get their f*&^ing integration to work. This exception should really be caught by MYOB Acumatica - it is not a bug on the part of NLog.

As we have discovered - and for the benefit of anybody else having the same problems and reading this - this can all be avoided by implementing one of the following solutions:

  • Renaming the nlog.config file, so NLog cannot configure itself. MYOB Acumatica ignores this and carries on its Mephistophelic way
  • Turning off logging by removing the “LogConfigurationFile” key added in the <appSettings> element in web.config
  • Installing a log manager like NXLog on localhost to listen to port 1514, although I’m not sure how to configure NXLog so that log messages can be reviewed
  • Changing nlog.config so that messages are written to a file instead of sent to a network port

I will be logging a ticket with MYOB asking them to fix this in future releases.

6 replies

benb1977
Freshman II
Forum|alt.badge.img
  • Freshman II
  • July 10, 2025

Hi John,

Did you ever get this sorted out? I am getting exactly the same error.

Cheers,

Ben.


Forum|alt.badge.img+1
  • Author
  • Varsity II
  • July 10, 2025

Hi Ben,

 

I sort of did.  At the moment my standard approach is to disable nLog all together on my local Dev instances.  It doesn’t seem to play well with a few fairly standard Microsoft CSharp classes.  HttpClient is one example.  I spent an age trying to resolve the issue in the link below.  Eventually got in front of the Acumatica support team and their advice was to turn nLog off.

 

 

I have a number of customisations that use HttpClient and none of them work properly on a local dev environment without disabling nLog.  I think the reason that I ran into the nLog issues on this post is I was messing around with settings trying to solve what is essentially a bug in the internal nLog code.  For some reason, under certain circumstances it just throws an error, and the fault isn’t with the customisation, it’s with nLog.

The last post at the very end of the topic in the link says how to turn nLog off.  This might solve your issue? Maybe give it a go.

Would be interested to hear if this fixes your problem.

 

John.

 


benb1977
Freshman II
Forum|alt.badge.img
  • Freshman II
  • July 11, 2025

Hi John,

Yes it did fix my problem, although I also found out some more details about this NLog product and how MYOB Acumatica uses it.

Firstly - another slightly cleaner way around this is to remove the line <add key="LogConfigurationFile" value="nlog.config" /> from web.config. A review of code in App_Code\Auxiliary\Initialization.cs confirms that NLog configuration will be bypassed if this key doesn’t exist or the configured file cannot be found.

Secondly - the nlog.config file is set up by default to try to send logging messages to port 1514 on localhost. A quick check in TCPView confirmed that there were no processes listening on port 1514, which is why the error “ConnectionRefused” appears. I found the dangerously similarly named product NXLog and installed it, configuring it to listen on port 1514. It seems that NXLog can be configured to write to an array of destination types including files, also performing niceties like cutting off files after a certain amount has been written, archiving files and other stuff.

Without modifying nlog.config, this fixed the “ConnectionRefused” error. But I couldn’t get NXLog to actually write any log messages. So I still wondered what these log messages were and why it only seemed to be my customisation that was logging them.

I then changed the nlog.config file so that instead of writing to a network port, it just wrote to a file. I changed the line:

<target name="nxlog" xsi:type="Network" newline="True" address="tcp4://localhost:1514">

to

<target name="file" xsi:type="File" lineEnding="Default" fileName="${basedir}\${level}.log">

And this gave me a file ‘Info.log’ in my MYOB Acumatica base directory. Looking in there, I could see that the messages being logged were server certificate checks, seemingly written when making requests to an https URL. And of course, there was still no ‘ConnectionRefused’ error getting in my way.

I don’t know why nlog.config was set up like it was with - out of the box - no possibility of any process listening on port 1514. It seems to be another oversight caused by the fact that outside MYOB staff, it’s really only developers that are installing the product.

Cheers,

Ben.


Forum|alt.badge.img+1
  • Author
  • Varsity II
  • July 18, 2025

Hi Ben,

 

Thanks for the extra info.  You’ve definately gone further down the nLog path than I did.  My approach is that nLog doesn’t add any value and there are a few bugs in it that cause system crashes, so I always just turn it off.

 

Presumably it has some value though, I just don’t understand what. Interesting that you found the logging was related to certificate checks calling a URL, and my experience is that nLog cause problems when making API calls within customisation code.  The two scenario’s seem to similar to be a coincidence.

 

Thoughts?


benb1977
Freshman II
Forum|alt.badge.img
  • Freshman II
  • Answer
  • July 18, 2025

Hi John,

Yes these are exactly the same scenario. The URL I am speaking of is part of an API exposed by a lease management software product, and like any API worth its salt, it is secured with HTTPS. I assume the API you’re connecting to is secured in the same way. Connecting to any URL through HTTPS requires a server certificate validation check, and it looks as though even in the case of a successful check, MYOB Acumatica feels the need to log it, specifically through NLog.

Out of the box, NLog is configured to send all log messages to TCP port 1514 on localhost. When it inevitably discovers that there is nothing listening on this port to accept the request, the I/O completion port throws an exception that is not caught by the application, crashing w3wp.exe and causing no end of profanity on the part of the developer just trying to get their f*&^ing integration to work. This exception should really be caught by MYOB Acumatica - it is not a bug on the part of NLog.

As we have discovered - and for the benefit of anybody else having the same problems and reading this - this can all be avoided by implementing one of the following solutions:

  • Renaming the nlog.config file, so NLog cannot configure itself. MYOB Acumatica ignores this and carries on its Mephistophelic way
  • Turning off logging by removing the “LogConfigurationFile” key added in the <appSettings> element in web.config
  • Installing a log manager like NXLog on localhost to listen to port 1514, although I’m not sure how to configure NXLog so that log messages can be reviewed
  • Changing nlog.config so that messages are written to a file instead of sent to a network port

I will be logging a ticket with MYOB asking them to fix this in future releases.


Forum|alt.badge.img+1
  • Author
  • Varsity II
  • July 18, 2025

Thanks heaps for explaining in more detail.  Very helpful.  Yep exact same scenario.  Have 3 examples where this has been a problem:

  • HTTPS requests to Simpro (maintenance planning software that does the same thing as MYOB/Acumatica but client likes it so much they wanted to keep it running and integrate to it)
  • HTTPS requests to Timetrak (fleet management software for a construction company)
  • HTTPS requests to MYOB/Acumatica for an intercompany integration (raise a purchase order on one system generate a sales order in the other,...)

I’m surpised this issue isn’t more prevelant on the Dev forum.  We can’t be the only ones doing API integrations within MYOB/Acumatica surely.  I suspect that this is an MYOB only problem and that most of the world is on Acumatica proper and don’t have the same sorts of issues.  Also for some reason the issue only seems present itself when the customization is in an extension library vs the code held internally in Acumatica.