[GH-ISSUE #278] System.Net.WebException when synchronizing Nextcloud Contacts and Contact Birthdays #1171

Closed
opened 2026-03-14 00:31:36 +03:00 by kerem · 9 comments
Owner

Originally created by @l0calh05t on GitHub (May 13, 2020).
Original GitHub issue: https://github.com/aluxnimm/outlookcaldavsynchronizer/issues/278

I've been getting frequent CalDavSynchronizer.DataAccess.WebDavClientException: An error occurred while sending the request. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. for a while now. I am on Nextcloud 18.0.4 with Contacts 3.3.0 and CalDav Synchronizer 3.8.0.0. No such issues on Tasks or the main Calendar.

Originally created by @l0calh05t on GitHub (May 13, 2020). Original GitHub issue: https://github.com/aluxnimm/outlookcaldavsynchronizer/issues/278 I've been getting frequent `CalDavSynchronizer.DataAccess.WebDavClientException: An error occurred while sending the request. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.` for a while now. I am on Nextcloud 18.0.4 with Contacts 3.3.0 and CalDav Synchronizer 3.8.0.0. No such issues on Tasks or the main Calendar.
kerem closed this issue 2026-03-14 00:31:41 +03:00
Author
Owner

@desperateCoder commented on GitHub (Jul 14, 2020):

Same for me, here is my full stacktrace:

CalDavSynchronizer.DataAccess.WebDavClientException:` An error occurred while sending the request. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Die zugrunde liegende Verbindung wurde geschlossen: Eine Verbindung, deren Aufrechterhaltung erwartet wurde, ist vom Server geschlossen worden..

   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)

   --- End of inner exception stack trace ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at System.Net.Http.HttpClient.<FinishSendAsync>d__58.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at CalDavSynchronizer.DataAccess.HttpClientBasedClient.WebDavClient.<ExecuteWebDavRequest>d__9.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at CalDavSynchronizer.DataAccess.HttpClientBasedClient.WebDavClient.<ExecuteWebDavRequestAndReadResponse>d__7.MoveNext()

   --- End of inner exception stack trace ---

   at CalDavSynchronizer.DataAccess.HttpClientBasedClient.WebDavClient.<ExecuteWebDavRequestAndReadResponse>d__7.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at CalDavSynchronizer.DataAccess.CalDavDataAccess.<GetVersions>d__29.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at CalDavSynchronizer.DataAccess.CalDavDataAccess.<GetVersions>d__29.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at CalDavSynchronizer.Implementation.CalDavRepository`1.<GetAllVersions>d__9.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at GenSync.EntityRepositories.VersionAwareToStateAwareEntityRepositoryAdapter`4.<GetFullRepositoryState>d__5.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at GenSync.Synchronization.Synchronizer`11.<Synchronize>d__27.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at GenSync.Synchronization.ContextCreatingSynchronizerDecorator`7.<Synchronize>d__3.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at CalDavSynchronizer.Scheduling.SynchronizationProfileRunner.<RunAndRescheduleNoThrow>d__22.MoveNext()

I'd like ta add, that we have configured 6 profiles, 5 calendars and one contacts. When sync runs, like two or three of them fail with this error, but not always the same ones. Seems to be quite random. Maybe there is a race condition on some resources or something?

Would be great if we get some feedback here, since this issue here is 2 months old.

Great work so far by the way, thanks for your work! It's pretty easy to use and works great, except when it fails like mentioned above

<!-- gh-comment-id:658012292 --> @desperateCoder commented on GitHub (Jul 14, 2020): Same for me, here is my full stacktrace: ``` CalDavSynchronizer.DataAccess.WebDavClientException:` An error occurred while sending the request. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Die zugrunde liegende Verbindung wurde geschlossen: Eine Verbindung, deren Aufrechterhaltung erwartet wurde, ist vom Server geschlossen worden.. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Net.Http.HttpClient.<FinishSendAsync>d__58.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CalDavSynchronizer.DataAccess.HttpClientBasedClient.WebDavClient.<ExecuteWebDavRequest>d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CalDavSynchronizer.DataAccess.HttpClientBasedClient.WebDavClient.<ExecuteWebDavRequestAndReadResponse>d__7.MoveNext() --- End of inner exception stack trace --- at CalDavSynchronizer.DataAccess.HttpClientBasedClient.WebDavClient.<ExecuteWebDavRequestAndReadResponse>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CalDavSynchronizer.DataAccess.CalDavDataAccess.<GetVersions>d__29.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at CalDavSynchronizer.DataAccess.CalDavDataAccess.<GetVersions>d__29.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CalDavSynchronizer.Implementation.CalDavRepository`1.<GetAllVersions>d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GenSync.EntityRepositories.VersionAwareToStateAwareEntityRepositoryAdapter`4.<GetFullRepositoryState>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GenSync.Synchronization.Synchronizer`11.<Synchronize>d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GenSync.Synchronization.ContextCreatingSynchronizerDecorator`7.<Synchronize>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CalDavSynchronizer.Scheduling.SynchronizationProfileRunner.<RunAndRescheduleNoThrow>d__22.MoveNext() ``` I'd like ta add, that we have configured 6 profiles, 5 calendars and one contacts. When sync runs, like two or three of them fail with this error, but not always the same ones. Seems to be quite random. Maybe there is a race condition on some resources or something? Would be great if we get some feedback here, since this issue here is 2 months old. Great work so far by the way, thanks for your work! It's pretty easy to use and works great, except when it fails like mentioned above
Author
Owner

@l0calh05t commented on GitHub (Jul 14, 2020):

I'd like ta add, that we have configured 6 profiles, 5 calendars and one contacts. When sync runs, like two or three of them fail with this error, but not always the same ones. Seems to be quite random. Maybe there is a race condition on some resources or something?

In my case two calendars, one contact list and one task list. But I only get failures on the contact birthday calendar and the contacts list. However, as in your case it seems to be nondeterministic if one, both, or neither fail to synchronize.

<!-- gh-comment-id:658033456 --> @l0calh05t commented on GitHub (Jul 14, 2020): > I'd like ta add, that we have configured 6 profiles, 5 calendars and one contacts. When sync runs, like two or three of them fail with this error, but not always the same ones. Seems to be quite random. Maybe there is a race condition on some resources or something? In my case two calendars, one contact list and one task list. But I only get failures on the contact birthday calendar and the contacts list. However, as in your case it seems to be nondeterministic if one, both, or neither fail to synchronize.
Author
Owner

@desperateCoder commented on GitHub (Jul 14, 2020):

@l0calh05t I think I found something:

  • go to profiles settings window
  • click "Show advanced settings" link at the bottom center on the window
  • you now should see some tree-structure under your profiles
  • select "Network settings" under your profile(s) (-> do it for each profile)
  • check the first ceckbox "close connection after each request" (or something like that)

To me, this makes perfect sense. The plugin tries to keep the connection alive, but the server might close it here and then, while the plugin thinks it is still open.

Just did that for the customer like 20 minutes ago, no errors since then, hopefully no more in the future, too 😅.

I'd suggest: give it a try and tell us, if the problem still persists for you, I can use this information for my customers as well.

Good luck to both of us! 😁

<!-- gh-comment-id:658088187 --> @desperateCoder commented on GitHub (Jul 14, 2020): @l0calh05t I think I found something: * go to profiles settings window * click "Show advanced settings" link at the bottom center on the window * you now should see some tree-structure under your profiles * select "Network settings" under your profile(s) (-> do it for each profile) * check the first ceckbox "close connection after each request" (or something like that) To me, this makes perfect sense. The plugin tries to keep the connection alive, but the server might close it here and then, while the plugin thinks it is still open. Just did that for the customer like 20 minutes ago, no errors since then, hopefully no more in the future, too :sweat_smile:. I'd suggest: give it a try and tell us, if the problem still persists for you, I can use this information for my customers as well. Good luck to both of us! :grin:
Author
Owner

@l0calh05t commented on GitHub (Jul 14, 2020):

I have checked the checkbox for the two profiles that keep failing (just as a note: they are all on the same server). I'll report back in a day or two.

<!-- gh-comment-id:658124591 --> @l0calh05t commented on GitHub (Jul 14, 2020): I have checked the checkbox for the two profiles that keep failing (just as a note: they are all on the same server). I'll report back in a day or two.
Author
Owner

@desperateCoder commented on GitHub (Jul 17, 2020):

For me, it didn't show up since then. How about you?

EDIT:
@aluxnimm Maybe this is something for the FAQ, or even better: maybe catch the error and reconnect automatically? But for me this issue is solved.

<!-- gh-comment-id:660039546 --> @desperateCoder commented on GitHub (Jul 17, 2020): For me, it didn't show up since then. How about you? EDIT: @aluxnimm Maybe this is something for the FAQ, or even better: maybe catch the error and reconnect automatically? But for me this issue is solved.
Author
Owner

@l0calh05t commented on GitHub (Jul 17, 2020):

Yep, no more errors. Very weird though that it only seems to affect some profiles, even though all of them are on the same server (didn't change the setting for the others).

@aluxnimm Maybe this is something for the FAQ, or even better: maybe catch the error and reconnect automatically? But for me this issue is solved.

I don't know if I would want to call it "solved", as we currently basically only have a workaround

<!-- gh-comment-id:660047783 --> @l0calh05t commented on GitHub (Jul 17, 2020): Yep, no more errors. Very weird though that it only seems to affect some profiles, even though all of them are on the same server (didn't change the setting for the others). > @aluxnimm Maybe this is something for the FAQ, or even better: maybe catch the error and reconnect automatically? But for me this issue is solved. I don't know if I would want to call it "solved", as we currently basically only have a workaround
Author
Owner

@desperateCoder commented on GitHub (Jul 17, 2020):

I don't know if I would want to call it "solved", as we currently basically only have a workaround

Agreed! I just meant that the workaround is ok for me, but I can imagine how other people struggle with this... As mentioned: the best solution would be recovering the error by establishing a new connection automatically.

<!-- gh-comment-id:660050237 --> @desperateCoder commented on GitHub (Jul 17, 2020): > I don't know if I would want to call it "solved", as we currently basically only have a workaround Agreed! I just meant that the workaround is ok for me, but I can imagine how other people struggle with this... As mentioned: the best solution would be recovering the error by establishing a new connection automatically.
Author
Owner

@l0calh05t commented on GitHub (Jul 17, 2020):

Automatic reconnect would be the expected behavior. Or at the very least documentation of the issue and the workaround.

I'll leave the issue open pending input from the maintainers.

<!-- gh-comment-id:660054108 --> @l0calh05t commented on GitHub (Jul 17, 2020): Automatic reconnect would be the expected behavior. Or at the very least documentation of the issue and the workaround. I'll leave the issue open pending input from the maintainers.
Author
Owner

@aluxnimm commented on GitHub (Sep 23, 2020):

It depends on your web server configuration and proxies in between how your keep-alive settings are defined.

And the error is already documented in the readme with the hint to use the network setting to close connection after each request.

<!-- gh-comment-id:697218849 --> @aluxnimm commented on GitHub (Sep 23, 2020): It depends on your web server configuration and proxies in between how your keep-alive settings are defined. And the error is already documented in the readme with the hint to use the network setting to close connection after each request.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/outlookcaldavsynchronizer#1171
No description provided.