Unable to call Azure search for specific asp.net .netframework 4.7.1 project (RequestFailedException) - azure-cognitive-search

I have a asp.net 4.7.1 project (upgraded to 4.7.1 during last 6-7 years) and I' not able to connect/call any method in Azure Searchc from within that project. I'm getting a RequestFailedException (Complete log at end)
Unfortunatly can I not reproduce in new Console app, new Asp.net 4.7.1 project!
I'm running all types of projects on same machine in same Visual Studio 2022.
I'm calling the Search service with the exact same code and same version of Nuget (11.3.0). (I have tried earlier versions as well 11.1.1, but same error).
I'm using the same service/index and key (Currently just a free service, but doesn't make any different if I run against other)
My testcode is:
var searchIndexClient = new SearchIndexClient(new
Uri($"https://sfsearchtest.search.windows.net"),
new AzureKeyCredential("70C978F2751C051E0BF156B0....."),
options);
noIndexes = searchIndexClient.GetIndexes().Count();
(I've obfuscated the key here)
It does not matter if I try callanothr method then "GetIndexes". Same error.
Note I have set MaxRetries = 0; But more retries gives same error so I have turned down to 0 retries.
Help really appreciated after a couple of days frustration/testing. And please do not ask me to update project to .Netcore ;-)
I have made a file compare between the ddls for "my project" compared to a newly created 4.7.1 project and they are exactly the same files.
Here is an error log (from AzureEventSourceListener.CreateConsoleLogger and
AzureEventSourceListener.CreateTraceLogger).
Azure-Core: [Informational] Request [916938f7-cc37-483b-a134-33ca2c69d22b] GET https://sfsearchtest.search.windows.net/indexes?$select=*&api-version=2020-06-30
Accept:application/json; odata.metadata=minimal
api-key:REDACTED
x-ms-client-request-id:916938f7-cc37-483b-a134-33ca2c69d22b
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Search.Documents/11.3.0 (.NET Framework 4.8.4420.0; Microsoft Windows 10.0.19044 )
client assembly: Azure.Search.Documents
Azure-Core: [Informational] Request [916938f7-cc37-483b-a134-33ca2c69d22b] GET https://sfsearchtest.search.windows.net/indexes?$select=*&api-version=2020-06-30
Accept:application/json; odata.metadata=minimal
api-key: REDACTED
x-ms-client-request-id:916938f7-cc37-483b-a134-33ca2c69d22b
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Search.Documents/11.3.0 (.NET Framework 4.8.4420.0; Microsoft Windows 10.0.19044 )
client assembly: Azure.Search.Documents
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'Azure.RequestFailedException' in Azure.Core.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Azure-Core: [Informational] Request [916938f7-cc37-483b-a134-33ca2c69d22b] exception Azure.RequestFailedException: The underlying connection was closed: An unexpected error occurred on a send.
at Azure.Core.Pipeline.HttpWebRequestTransport.<ProcessInternal>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 Azure.Core.Pipeline.HttpWebRequestTransport.Process(HttpMessage message)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.RequestActivityPolicy.ProcessNextAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
at Azure.Core.Pipeline.RequestActivityPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>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 Azure.Core.Pipeline.ResponseBodyPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.LoggingPolicy.<ProcessAsync>d__9.MoveNext()
Azure-Core: [Informational] Request [916938f7-cc37-483b-a134-33ca2c69d22b] exception Azure.RequestFailedException: The underlying connection was closed: An unexpected error occurred on a send.
at Azure.Core.Pipeline.HttpWebRequestTransport.<ProcessInternal>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 Azure.Core.Pipeline.HttpWebRequestTransport.Process(HttpMessage message)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.RequestActivityPolicy.ProcessNextAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
at Azure.Core.Pipeline.RequestActivityPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.ResponseBodyPolicy.<ProcessAsync>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 Azure.Core.Pipeline.ResponseBodyPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.LoggingPolicy.<ProcessAsync>d__9.MoveNext()
Exception thrown: 'Azure.RequestFailedException' in Azure.Core.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Exception thrown: 'Azure.RequestFailedException' in mscorlib.dll
Exception thrown: 'Azure.RequestFailedException' in Azure.Search.Documents.dll

Ok. I managed to solve it. Short answer for now:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;
The Tls have caused problems before. Not sure why my old project causes problems with this (could not find anything about tls). Luckely this worked :)

Related

How to change solr.jetty.request.header.size in docker

I have created a Solr version 8.1.1 in Azure using a Docker for Sitecore. I get the following error for a large query
ERROR Error during executing a query.
Exception: SolrNet.Exceptions.SolrConnectionException
Message: <h1>Bad Message 431</h1><pre>reason: Request Header Fields Too Large</pre>
Source: SolrNet
at SolrNet.Impl.SolrConnection.Get(String relativeUrl, IEnumerable`1 parameters)
at SolrNet.Impl.SolrQueryExecuter`1.Execute(ISolrQuery q, QueryOptions options)
at Sitecore.ContentSearch.SolrProvider.LinqToSolrIndex`1.ExecuteQuery(SolrCompositeQuery compositeQuery, QueryOptions options)
Nested Exception
Exception: System.Net.WebException
Message: The remote server returned an error: (431) Request Header Fields Too Large.
Source: System
at System.Net.HttpWebRequest.GetResponse()
at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse()
at SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request)
at SolrNet.Impl.SolrConnection.Get(String relativeUrl, IEnumerable`1 parameters)
I managed to resolve the issue by redeploy the Docker instance by updating the YML file with the following setting under environment section.
- SOLR_OPTS=-Dsolr.jetty.request.header.size=65535

Angular receiving a 500 error but the server is completing the action with no issue?

I am calling a WebApi Method that adds to a database. This method succeeds and throws no exceptions; however angular gets a 500 error:
POST "MyServer" 500 (Internal Server Error)angular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:250
(anonymous function)angular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:245
mangular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:243
fangular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:274
(anonymous function)angular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:288
k.$evalangular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:285
k.$digestangular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:289
k.$applyangular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:390
(anonymous function)angular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:3
n.event.dispatchangular?v=jZUm0Uxsk4Ig_MVBcIx2KTRnLbeaXFiNS47wjLSNXC01:3 r.handle
All of this is internal angular code and I am not sure where / how to debug this stuff
angular service
this.add = function (myObject) {
$http({
method: "POST",
url: "api/theServer/Add/",
data: myObject
});
};
WebApi
[Route("Add/"), HttpPost]
public void Add(MyObject myObject)
{
_service.Add(waiver);
}
The data is saved to the database just fine, however angular is throwing an error and is not updating the page
This is returned from the server:
The specified policy origin 'MyServer' is invalid. It must not contain a path, query, or fragment
UPDATE
"Message": "An error has occurred.",
"ExceptionMessage": "The specified policy origin 'MyServer' is invalid. It must not contain a path, query, or fragment.",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Web.Http.Cors.EnableCorsAttribute.ValidateOrigins(IList`1 origins)\r\n at System.Web.Http.Cors.EnableCorsAttribute.GetCorsPolicyAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Cors.CorsMessageHandler.<GetCorsPolicyAsync>d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Cors.CorsMessageHandler.<HandleCorsRequestAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Cors.CorsMessageHandler.<SendAsync>d__0.MoveNext()"
This is the full stack returned from Postman
Your Web browser is not permitting information to be fetched from a third-party site. The request is being sent fine, but javascript is not permitted to process the response because it is from an untrusted source.
You have several options, the most common being:
Add a rewrite proxy into your origin server to forward packets
to the remote server
Enable CORS support on your origin server
to permit cross-domain requests
Alternatively, it might be that you have CORS enabled already, but your "MyServer" host is not in the permitted domain list.

java.io.IOException ,when i go one page to another page it will give error but flow dose not intrupted and error is java.io.IOException: Stream closed

SEVERE: Servlet.service() for servlet [jsp] in context with path [/MAT] threw exception [java.lang.IllegalStateException: Exception occurred when flushing data] with root cause
java.io.IOException: Stream closed

DNN : SSL enabled site but host menu not working

I have a dnn website which I have configured as secure. After making it secure whenever I access secure pages of host menu, it throws error and I am unable to access host secure pages.
Please help me ASAP!
Error Details :
Method: DotNetNuke.Entities.Portals.PortalSettings.GetPortalSettings
StackTrace:
Message: System.Exception: Unhandled Error: ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Entities.Portals.PortalSettings.GetPortalSettings(Int32 TabId, PortalAliasInfo objPortalAliasInfo) at DotNetNuke.Entities.Portals.PortalSettings..ctor(Int32 tabId, PortalAliasInfo objPortalAliasInfo) at DotNetNuke.HttpModules.UrlRewriteModule.OnBeginRequest(Object s, EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --- End of inner exception stack trace ---
Thanks,
Kusum
Try to re-install your certificate
Clear Web Browser Cache
Restart Site (add a white space to your web.config file and save)

Grails App unable to connect to SQL Server (Malformed Reply from SOCKS Server)

I'm a newbie learning Grails by developing a small application that retrieves codes from a database. The details are -
- Apple Mac OS X (i.e. Unix).
- Grails 1.3.5 using NetBeans 6.9.1.
- SQL Server 2008 R2 Database, located on a different server.
- JTDS Driver
Here is the DataSource.groovy -
dataSource {
pooled = false
driverClassName = "net.sourceforge.jtds.jdbc.Driver"
dialect="org.hibernate.dialect.SQLServerDialect"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:jtds:sqlserver://hbtsqldev.domain.omitted.com.au:1433;databasename=TempDatabase;useCursorFetch=true;user=username;password=omitted"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:jtds:sqlserver://hbtsqldev.domain.omitted.com.au:1433;databasename=TempDatabase;useCursorFetch=true;user=username;password=omitted"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:jtds:sqlserver://hbtsqldev.domain.omitted.com.au:1433;databasename=TempDatabase;useCursorFetch=true;user=username;password=omitted"
}
}
}
When I run the Grails app, I receive the following (very long) error messages -
2010-11-11 10:58:00,709 [main] ERROR
context.GrailsContextLoader - Error
executing bootstraps: Error creating
bean with name 'messageSource':
Initialization of bean failed; nested
exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'transactionManager': Cannot resolve
reference to bean 'sessionFactory'
while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'sessionFactory': Cannot resolve
reference to bean 'lobHandlerDetector'
while setting bean property
'lobHandler'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'lobHandlerDetector': Invocation of
init method failed; nested exception
is
org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting
DatabaseMetaData; nested exception is
java.sql.SQLException: Network error
IOException: Malformed reply from
SOCKS server
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'messageSource': Initialization of
bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'transactionManager': Cannot resolve
reference to bean 'sessionFactory'
while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'sessionFactory': Cannot resolve
reference to bean 'lobHandlerDetector'
while setting bean property
'lobHandler'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'lobHandlerDetector': Invocation of
init method failed; nested exception
is
org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting
DatabaseMetaData; nested exception is
java.sql.SQLException: Network error
IOException: Malformed reply from
SOCKS server at
org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:212)
at
grails.web.container.EmbeddableServer$start.call(Unknown
Source) at
_GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at
_GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at
_GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at
_GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at
_GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at
_GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at
_GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
at
_GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at
_GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) at
RunApp$_run_closure1.doCall(RunApp.groovy:33) at
gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at
gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at
gant.Gant$_dispatch_closure7.doCall(Gant.groovy) at
gant.Gant.withBuildListeners(Gant.groovy:427)
at
gant.Gant.this$2$withBuildListeners(Gant.groovy)
at
gant.Gant$this$2$withBuildListeners.callCurrent(Unknown
Source) at
gant.Gant.dispatch(Gant.groovy:415)
at
gant.Gant.this$2$dispatch(Gant.groovy)
at
gant.Gant.invokeMethod(Gant.groovy)
at
gant.Gant.executeTargets(Gant.groovy:590)
at
gant.Gant.executeTargets(Gant.groovy:589)
Caused by:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'transactionManager': Cannot resolve
reference to bean 'sessionFactory'
while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'sessionFactory': Cannot resolve
reference to bean 'lobHandlerDetector'
while setting bean property
'lobHandler'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'lobHandlerDetector': Invocation of
init method failed; nested exception
is
org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting
DatabaseMetaData; nested exception is
java.sql.SQLException: Network error
IOException: Malformed reply from
SOCKS server ... 23 more Caused by:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'sessionFactory': Cannot resolve
reference to bean 'lobHandlerDetector'
while setting bean property
'lobHandler'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'lobHandlerDetector': Invocation of
init method failed; nested exception
is
org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting
DatabaseMetaData; nested exception is
java.sql.SQLException: Network error
IOException: Malformed reply from
SOCKS server ... 23 more Caused by:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'lobHandlerDetector': Invocation of
init method failed; nested exception
is
org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting
DatabaseMetaData; nested exception is
java.sql.SQLException: Network error
IOException: Malformed reply from
SOCKS server ... 23 more Caused by:
org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting
DatabaseMetaData; nested exception is
java.sql.SQLException: Network error
IOException: Malformed reply from
SOCKS server ... 23 more Caused by:
java.sql.SQLException: Network error
IOException: Malformed reply from
SOCKS server at
net.sourceforge.jtds.jdbc.ConnectionJDBC2.(ConnectionJDBC2.java:410)
at
net.sourceforge.jtds.jdbc.ConnectionJDBC3.(ConnectionJDBC3.java:50)
at
net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at
java.sql.DriverManager.getConnection(DriverManager.java:582)
at
java.sql.DriverManager.getConnection(DriverManager.java:154)
at $Proxy8.getMetaData(Unknown
Source) ... 23 more Caused by:
java.net.SocketException: Malformed
reply from SOCKS server at
java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:147)
at
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:495)
at
java.net.Socket.connect(Socket.java:529)
at
net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
at
net.sourceforge.jtds.jdbc.SharedSocket.(SharedSocket.java:257)
at
net.sourceforge.jtds.jdbc.ConnectionJDBC2.(ConnectionJDBC2.java:311)
... 28 more
Can anyone see where the problem might be?
If you need me to provide any further info, please let me know.
Are you able to ping the database server from where you are running your tomcat? I am using Grails 1.3.5 with SQL Server 2005 with Microsoft JDBC 4.0 Driver. Works fine for me.
dataSource.driverClassName = com.microsoft.sqlserver.jdbc.SQLServerDriver
dataSource.url = jdbc:sqlserver://dbserver:1433;databaseName=testDB

Resources