SaintAngeLs / courier_app

Courier-hub application build up with .net and React
2 stars 0 forks source link

Need help with this issue. #84

Open SaintAngeLs opened 10 months ago

SaintAngeLs commented 10 months ago
[04:29:26 INF] Executing endpoint '405 HTTP Method Not Supported'
[04:29:26 INF] Executed endpoint '405 HTTP Method Not Supported'
[04:29:26 INF] Request finished HTTP/1.1 POST http://localhost:5292/parcels/parcels application/json 680 - 405 0 - 3.2296ms
[04:32:26 INF] Request starting HTTP/1.1 POST http://localhost:5292/parcels/parcels application/json 680
[04:32:26 INF] Executing endpoint '405 HTTP Method Not Supported'
[04:32:26 INF] Executed endpoint '405 HTTP Method Not Supported'
[04:32:26 INF] Request finished HTTP/1.1 POST http://localhost:5292/parcels/parcels application/json 680 - 405 0 - 0.7810ms

┌──(kaliuser㉿kali)-[~/…/courierapp/courier_app/SwiftParcel.Web/frontend]
└─$ curl -X 'POST' \
  'http://localhost:5292/parcels/parcels' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "ParcelId": "00000000-0000-0000-0000-000000000000",
  "CustomerId": "00000000-0000-0000-0000-000000000000",
  "Description": null,
  "Width": 0,
  "Height": 0,
  "Depth": 0,
  "Weight": 0,
  "SourceStreet": null,
  "SourceBuildingNumber": null,
  "SourceApartmentNumber": null,
  "SourceCity": null,
  "SourceZipCode": null,
  "SourceCountry": null,
  "DestinationStreet": null,
  "DestinationBuildingNumber": null,
  "DestinationApartmentNumber": null,
  "DestinationCity": null,
  "DestinationZipCode": null,
  "DestinationCountry": null,
  "Priority": "high",
  "AtWeekend": false,
  "PickupDate": null,
  "DeliveryDate": null,
  "IsCompany": false,
  "VipPackage": false
}'

┌──(kaliuser㉿kali)-[~/…/courierapp/courier_app/SwiftParcel.Web/frontend]
└─$ curl -X 'POST' \
  'http://localhost:5007/parcels' \ 
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "ParcelId": "00000000-0000-0000-0000-000000000000",
  "CustomerId": "00000000-0000-0000-0000-000000000000",
  "Description": null,
  "Width": 0,
  "Height": 0,
  "Depth": 0,
  "Weight": 0,
  "SourceStreet": null,
  "SourceBuildingNumber": null,
  "SourceApartmentNumber": null,
  "SourceCity": null,
  "SourceZipCode": null,
  "SourceCountry": null,
  "DestinationStreet": null,
  "DestinationBuildingNumber": null,
  "DestinationApartmentNumber": null,
  "DestinationCity": null,
  "DestinationZipCode": null,
  "DestinationCountry": null,
  "Priority": "high",
  "AtWeekend": false,
  "PickupDate": null,
  "DeliveryDate": null,
  "IsCompany": false,
  "VipPackage": false
}'
{"code":"invalid_parcel_datetime_property","reason":"Parcel DateTime property (pickup_date) is invalid: ."}                                                                                                                                                                                                                                            
┌──(kaliuser㉿kali)-[~/…/courierapp/courier_app/SwiftParcel.Web/frontend]
└─$ 

[04:32:26 INF] Request finished HTTP/1.1 POST http://localhost:5292/parcels/parcels application/json 680 - 405 0 - 0.7810ms [04:38:24 INF] Request starting HTTP/1.1 POST http://localhost:5292/parcels/parcels application/json 680 [04:38:24 INF] Executing endpoint '405 HTTP Method Not Supported' [04:38:24 INF] Executed endpoint '405 HTTP Method Not Supported' [04:38:24 INF] Request finished HTTP/1.1 POST http://localhost:5292/parcels/parcels application/json 680 - 405 0 - 0.7327ms

SaintAngeLs commented 10 months ago

This issue was occasionally closed.

SaintAngeLs commented 10 months ago

This issue is not resolved.

eggwhat commented 10 months ago

I'm not sure what are you trying to achieve here. In first case there is wrong url and in the second one it fails field validation in json data.

SaintAngeLs commented 10 months ago

@eggwhat, please check if the request is correct:

    cons payload = ...;
    console.log("Request payload:", payload);

    const inquiryResponse = await api.post(`/parcels`, payload, {
      headers: { Authorization: `${userInfo.accessToken}` }
    });
some example request payload is:

```json

{
"CustomerId": "18fee8d9-c617-4fa2-83b1-a8ba2e722359",
"Description": "Test",
"Width": 0.05,
"Height": 0.05,
"Depth": 0.05,
"Weight": 0.5,
"SourceStreet": "Plac politechniki",
"SourceBuildingNumber": "1",
"SourceApartmentNumber": "",
"SourceCity": "Warszawa",
"SourceZipCode": "00-420",
"SourceCountry": "Polska",
"DestinationStreet": "Koszykowa",
"DestinationBuildingNumber": "21",
"DestinationApartmentNumber": "37",
"DestinationCity": "Warszawa",
"DestinationZipCode": "00-420",
"DestinationCountry": "Polska",
"Priority": "Low",
"AtWeekend": true,
"PickupDate": "2023-12-22T00:00:00.000Z",
"DeliveryDate": "2023-12-29T00:00:00.000Z",
"IsCompany": false,
"VipPackage": false

}

SaintAngeLs commented 10 months ago

Also there is an exception in the parcel serivece:

[12:28:32 INF] End processing HTTP request - NotFound
[12:28:32 ERR] There was an error when processing a message with id: '0182b89fedb94d139d0c9c6fdcb6b969'.
SwiftParcel.Services.Parcels.Application.Exceptions.PricingServiceException: Pricing service error occured for parcel with id: 05b8951c-b229-45a9-a37c-e87819b9222a.
   at SwiftParcel.Services.Parcels.Application.Commands.Handlers.AddParcelHandler.HandleAsync(AddParcel command, CancellationToken cancellationToken) in /home/kaliuser/Documents/portfolio/commercial_apps/courierapp/courier_app/SwiftParcel.Services.Parcels/src/SwiftParcel.Services.Parcels.Application/SwiftParcel.Services.Parcels.Application/Commands/Handlers/AddParcelHandler.cs:line 63
   at Convey.MessageBrokers.Outbox.Mongo.Internals.MongoMessageOutbox.HandleAsync(String messageId, Func`1 handler)
[12:28:32 INF] Executed endpoint 'parcels HTTP: POST'
[12:28:32 ERR] Pricing service error occured for parcel with id: 05b8951c-b229-45a9-a37c-e87819b9222a.
SwiftParcel.Services.Parcels.Application.Exceptions.PricingServiceException: Pricing service error occured for parcel with id: 05b8951c-b229-45a9-a37c-e87819b9222a.
   at SwiftParcel.Services.Parcels.Application.Commands.Handlers.AddParcelHandler.HandleAsync(AddParcel command, CancellationToken cancellationToken) in /home/kaliuser/Documents/portfolio/commercial_apps/courierapp/courier_app/SwiftParcel.Services.Parcels/src/SwiftParcel.Services.Parcels.Application/SwiftParcel.Services.Parcels.Application/Commands/Handlers/AddParcelHandler.cs:line 63
   at Convey.MessageBrokers.Outbox.Mongo.Internals.MongoMessageOutbox.HandleAsync(String messageId, Func`1 handler)
   at Convey.MessageBrokers.Outbox.Mongo.Internals.MongoMessageOutbox.HandleAsync(String messageId, Func`1 handler)
   at Convey.Logging.CQRS.Decorators.CommandHandlerLoggingDecorator`1.HandleAsync(TCommand command, CancellationToken cancellationToken)
   at Convey.CQRS.Commands.Dispatchers.CommandDispatcher.SendAsync[T](T command, CancellationToken cancellationToken)
   at Convey.WebApi.CQRS.Builders.DispatcherEndpointsBuilder.BuildCommandContext[T](T command, HttpContext context, Func`3 beforeDispatch, Func`3 afterDispatch)
   at Convey.WebApi.EndpointsBuilder.BuildRequestContext[T](HttpContext httpContext, Func`3 context)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at App.Metrics.AspNetCore.Tracking.Middleware.ApdexMiddleware.MeasureTransaction(HttpContext context)
   at App.Metrics.AspNetCore.Tracking.Middleware.PerRequestTimerMiddleware.TimeTransaction(HttpContext context)
   at App.Metrics.AspNetCore.Tracking.Middleware.RequestTimerMiddleware.TimeTransaction(HttpContext context)
   at App.Metrics.AspNetCore.Tracking.Middleware.ErrorRequestMeterMiddleware.Invoke(HttpContext context)
   at App.Metrics.AspNetCore.Tracking.Middleware.ActiveRequestCounterEndpointMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Convey.WebApi.Exceptions.ErrorHandlerMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[12:28:32 INF] Request finished HTTP/1.1 POST http://localhost:5007/parcels application/json 993 - 400 - application/json 132.2098ms

it is not connected to fabio for http requests

SaintAngeLs commented 10 months ago

@an2508374 , @eggwhat please, show me the request which is working for you for the POST /parcels.

eggwhat commented 10 months ago

So in post request you need to provide parcelId, you should use empty guid like in the commented code, backend will create real id. Also you need to provide customerId: empty guid if the user is not logged in, and exisiting customerId if he is logged in.

eggwhat commented 10 months ago

I was using local addresses without fabio (similar to #88 ) and everything worked fine. I was looking how to fix the issue with fabio enabled and when i run fabio on ports 9998 9999, i see on port 9998 that the routing table is empty. I don't know if it the cause of this issue

SaintAngeLs commented 10 months ago

The for the fabio seeing the services, services should have been contenerised. In this case, if there will any update need for the service the whole container should be force recreated which is not that efficient to do it every time. So for now, if there is any http communication need for the services to work, lets use the 'hard-coded' endpoints for the http client endpoints.

SaintAngeLs commented 10 months ago

I was using local addresses without fabio (similar to #88 ) and everything worked fine. I was looking how to fix the issue with fabio enabled and when i run fabio on ports 9998 9999, i see on port 9998 that the routing table is empty. I don't know if it the cause of this issue

The fabio sees only the contenerised images of the services.

SaintAngeLs commented 10 months ago

The identity is connected to the fabio and there is not issue communicating with it through the apigateway. For the parcelsService I see:

1:53:03 INF] Request starting HTTP/1.1 OPTIONS http://localhost:5292/parcels - -
[01:53:03 INF] CORS policy execution successful.
[01:53:03 INF] Request finished HTTP/1.1 OPTIONS http://localhost:5292/parcels - - - 204 - - 1.3911ms
[01:53:03 INF] Request starting HTTP/1.1 POST http://localhost:5292/parcels application/json 643
[01:53:03 INF] CORS policy execution successful.
[01:53:03 INF] Executing endpoint 'parcels HTTP: POST'
[01:53:03 INF] Sending HTTP POST request to: http://localhost:5007/parcels [Trace ID: 0HN0439JM42MR:00000007]
[01:53:03 INF] Start processing HTTP request POST http://localhost:5007/parcels
[01:53:03 INF] Sending HTTP request POST http://localhost:5007/parcels
[01:53:03 INF] Received HTTP response headers after 5.0888ms - 400
[01:53:03 INF] End processing HTTP request after 7.1643ms - 400
[01:53:03 INF] Received an invalid response (BadRequest) to HTTP POST request from: parcels-service/parcels [Trace ID: 0HN0439JM42MR:00000007]
[01:53:03 INF] Executed endpoint 'parcels HTTP: POST'
[01:53:03 INF] Request finished HTTP/1.1 POST http://localhost:5292/parcels application/json 643 - 400 - - 12.9098ms

Any propositions how to resolve this?

SaintAngeLs commented 10 months ago

I will try to connect the fabio in the docker container with the existing services.

SaintAngeLs commented 10 months ago

The currect issue is:

xhr.js:247     POST http://localhost:5292/parcels 400 (Bad Request)
dispatchXhrRequest @ xhr.js:247
xhr @ xhr.js:49
dispatchRequest @ dispatchRequest.js:51
request @ Axios.js:142
httpMethod @ Axios.js:181
wrap @ bind.js:5
createInquiry @ api.tsx:226
await in createInquiry (async)
onSubmit @ createInquiry.tsx:455
callCallback @ react-dom.development.js:4164
invokeGuardedCallbackDev @ react-dom.development.js:4213
invokeGuardedCallback @ react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291
executeDispatch @ react-dom.development.js:9041
processDispatchQueueItemsInOrder @ react-dom.development.js:9073
processDispatchQueue @ react-dom.development.js:9086
dispatchEventsForPlugins @ react-dom.development.js:9097
(anonymous) @ react-dom.development.js:9288
batchedUpdates$1 @ react-dom.development.js:26140
batchedUpdates @ react-dom.development.js:3991
dispatchEventForPluginEventSystem @ react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465
dispatchEvent @ react-dom.development.js:6457
dispatchDiscreteEvent @ react-dom.development.js:6430
api.tsx:253 Error during inquiry creation (Axios error): An invalid JSON was sent.
SaintAngeLs commented 10 months ago

I was using local addresses without fabio (similar to #88 ) and everything worked fine. I was looking how to fix the issue with fabio enabled and when i run fabio on ports 9998 9999, i see on port 9998 that the routing table is empty. I don't know if it the cause of this issue

Tell what is everything. Provide the changes in the frontendUpdate with the local endpoints and show it's working.

eggwhat commented 10 months ago

For me the createInquire request works if I use updated ntrada.yml file from apigateway branch and in request payload there is an empty guid parcelId. I also don't know why there is authorization header.

SaintAngeLs commented 10 months ago

The 'forntentUpdate2' branch resolving this issue in some point. 'apigateway' branch update resolves this issue.