Closed warrenroscoe closed 3 years ago
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Hi, I have managed to circumvent this issue (for now). I checked my internet speed, and upload speed was poor. I followed advice in https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/slow-internet-speed-on-windows-10-1809/022c16ef-3c69-4472-b7e9-d0b7466916fc#:~:text=Slower%20internet%20speed%20after%20Windows,for%20the%20Windows%2010%20update.&text=Check%20for%20Receive%20Window%20Auto,will%20need%20to%20disable%20it. and this managed to fix the issue.
Therefore, closing the issue. Happy Xmas!
Category
Describe the bug
When running the script below dring office hours, I am pretty much always getting the exception below on both the Get-PnPTenantTemplate and Get-PnPProvisioningTemplate commands. I have tried various script tweaks (ServicePointManager settings) from documented fixes on the internet ... they are in the code, but still I cant get either of the commands above to work reliably. Are there any tweaks required to the script or settings somewhere that I need to change that will help with reliability?
Exception is: "Get-PnPProvisioningTemplate : The underlying connection was closed: A connection that was expected to be kept alive was closed by the server."
Steps to reproduce
Run the script below, adding a valid account, password and url.
param ( [switch] $register , [switch] $getPnP , [switch] $applyPnP )
<# cls;.\O365build.ps1 -getPnP
>
<# Remove-Module -Name SharePointPnPPowerShellOnline Import-Module -Name SharePointPnPPowerShellOnline
>
$startDate = Get-Date; Write-Host $("Starting ... $startDate") -BackgroundColor DarkGreen -ForegroundColor Yellow;
[System.Net.ServicePointManager]::Expect100Continue = $false;
[System.Net.ServicePointManager]::DefaultConnectionLimit = 6; [System.Net.ServicePointManager]::MaxServicePointIdleTime = 20000;
try { $username = "" $password = "" $adminSiteUrl = "https://something-admin.sharepoint.com" $sourceSiteUrl = "https://something.sharepoint.com/sites/PnPBuildTest" $destinationSiteUrl = "https://something.sharepoint.com/sites/PnPBuildTarget" $tenentTemplateFile = "C:\TEMP\TenantTemplate-PnPBuildTest.xml" $tenantTemplateConfiguration = "C:\Projects\Modules\O365build-tenanttemplate-config.json" $logFile = "C:\TEMP\pnpTraceOutput.txt"
} catch { $catch = $_.exception Write-Host "
n
nEXCEPTION" -BackgroundColor Red -ForegroundColor Yellow Write-Host $catch.GetType().FullName -BackgroundColor Red -ForegroundColor Yellow Write-Host $catch.ScriptStackTrace -BackgroundColor Red -ForegroundColor Yellow Write-Host $catch.Exception.Message -BackgroundColor Red -ForegroundColor Yellow Write-Host $catch.Exception.StackTrace -BackgroundColor Red -ForegroundColor Yellow if ($catch.Exception.InnerException -ne $null) { Write-Host $catch.Exception.InnerException.Message -BackgroundColor Red -ForegroundColor Yellow Write-Host $catch.Exception.InnerException.StackTrace -BackgroundColor Red -ForegroundColor Yellow } }$endDate = Get-Date; Write-Host $("Finishing ... $endDate") -BackgroundColor DarkGreen -ForegroundColor Yellow; Write-Host $("Duration ... {0:hh\:mm\:ss.fff}" -f $(New-TimeSpan –Start $startDate –End $endDate)) -BackgroundColor DarkGreen -ForegroundColor Yellow;
Expected behavior
No exception
Environment details (development & target environment)
SDK version: 3.26.2010.0 (for SharePointPnPPowerShellOnline)
OS: Windows 10
SDK used in: SharePointPnPPowerShellOnline
PSChildName Version
Client 4.8.03752 Full 4.8.03752 Client 4.0.0.0
Browser(s):
Tooling:
Additional details:
$psversiontable
Name Value
PSVersion 5.1.18362.1171 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.18362.1171 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Additional context
The full exception is:
"powershell.exe",Error,0,"2020-11-16 18:33:39.7688 [OfficeDevPnP.Core] [0] [Error] ExecuteQuery threw following exception: System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactoryd0.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 Microsoft.SharePoint.Client.ClientRequest.d 6.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 Microsoft.SharePoint.Client.ClientRequest.d0.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 Microsoft.SharePoint.Client.ClientRuntimeContext.d 0.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 Microsoft.SharePoint.Client.ClientContext.d4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.SharePoint.Client.ClientContextExtensions.d 7.MoveNext()
. 0ms ",,,,,"2020-11-16T18:33:39.7688523Z",,
"powershell.exe",Information,0,"2020-11-16 18:33:39.7728 [Site Security] [14] [Debug] Code execution scope ended 78305ms 67633e81-8917-45f9-af01-aa7779e7ef0d",,,,,"2020-11-16T18:33:39.7728458Z",,
"powershell.exe",Information,0,"2020-11-16 18:33:39.7728 [Extraction] [14] [Debug] Code execution scope ended 801209ms 67633e81-8917-45f9-af01-aa7779e7ef0d",,,,,"2020-11-16T18:33:39.7728458Z",,
1.FromAsyncCoreLogic(IAsyncResult iar, Func
2 endFunction, Action1 endAction, Task
1 promise, Boolean requiresSynchronization) --- 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 Microsoft.SharePoint.Client.SPWebRequestExecutor.Thanks for your contribution! Sharing is caring.