Unable to connection elastic cloud into online website but working fine into local system


(sangeet shah) #1

i have login into elastic cloud and get the cloud url and password to connect this account from c# language and able to index and search my index data from cloud elastic.

I have created application into .net core c# and working fine into local pc with indexing,searching and etc action but this not working into my website. it give me error as below mention:-

Short message	
One or more errors occurred. (An attempt was made to access a socket in a way forbidden by its access permissions)
Full message	
System.AggregateException: One or more errors occurred. (An attempt was made to access a socket in a way forbidden by its access permissions) ---> System.Net.Http.HttpRequestException: An attempt was made to access a socket in a way forbidden by its access permissions ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Nop.Web.Areas.Admin.Custom.Service.ElasticSearchService.SuggestedProductAsync(String keyword, Int32 pageIndex, Int32 pageSize)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Nop.Web.Factories.CatalogModelFactory.PrepareElasticSearchModel(SearchModel model, CatalogPagingFilteringModel command)
   at Nop.Web.CustomCode.Controllers.ElasticSearchController.Search(SearchModel model, CatalogPagingFilteringModel command)
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 86
   at Nop.Services.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) in D:\Sangeet Shah\Project\ElasticSearch\Libraries\Nop.Services\Authentication\AuthenticationMiddleware.cs:line 79
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Nop.Core.Http.InstallUrlMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in D:\Sangeet Shah\Project\ElasticSearch\Libraries\Nop.Core\Http\InstallUrlMiddleware.cs:line 51
   at Nop.Core.Http.KeepAliveMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in D:\Sangeet Shah\Project\ElasticSearch\Libraries\Nop.Core\Http\KeepAliveMiddleware.cs:line 50
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
---> (Inner Exception #0) System.Net.Http.HttpRequestException: An attempt was made to access a socket in a way forbidden by its access permissions ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Nop.Web.Areas.Admin.Custom.Service.ElasticSearchService.SuggestedProductAsync(String keyword, Int32 pageIndex, Int32 pageSize)<-

my code look like this :-
var settings = new ConnectionSettings(new Uri("http://username:password@elasticurl"))
.DefaultIndex("people");

            var client = new ElasticClient(settings);
            var person = new Person
            {
                Id = 1,
                FirstName = "Martijn",
                LastName = "Laarman"
            };
            var indexResponse = client.IndexDocument(person);
            var asyncIndexResponse = client.IndexDocumentAsync(person);

for searching code
ISearchResponse searchResponse = elasticClient.SearchAsync(s => s
//.Index(indexName)
.Suggest(su => su
.Completion("suggestions", c => c
.Field(f => f.Suggest)
.Prefix(keyword)
.Fuzzy(f => f
.Fuzziness(Fuzziness.Auto)
))).Skip(skipno).Take(pageSize));

            if (searchResponse.Suggest == null || !searchResponse.Suggest.Any())
                return null;

            var query = from suggest in searchResponse.Suggest["suggestions"]
                        from option in suggest.Options
                        select option.Source;

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.