Traefik as an ingress controller + Server GRPC - UNKNOWN: No status received - grpc

I use traefik as an ingress controller in AKS, I have a grpc service that run correctly locally, but I have some problem behind traefik.
When the GRPC server return an error, I receive it correctly, but when it send a normal response, I didn’t receive it:
grpcServer#grpc.test.com:443> client.Ping({}, metadata, pr)
EventEmitter {}
grpcServer#grpc.test.com:443>
Error: { Error: 2 UNKNOWN: No status received
at Object.exports.createStatusError (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:1204:28)
at InterceptingListener._callNext (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:845:24) code: 2, metadata: {}, details: 'No status received' }
vs
grpcServer#localhost:10000> client.Ping({}, metadata, pr)
EventEmitter {}
grpcServer#localhost:10000>
{
"response": "PONG"
}
Error:
grpcServer#grpc.test.com:443> client.Ping({}, pr)
EventEmitter {}
grpcServer#grpc.test.com:443>
Error: { Error: 16 UNAUTHENTICATED: incorrect serial number
at Object.exports.createStatusError (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:1204:28)
at InterceptingListener._callNext (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:845:24)
code: 16,
metadata:
{ 'content-length': '0', date: 'Wed, 06 Feb 2019 21:32:38 GMT' },
details: 'incorrect serial number' }
The k8s service yml:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: velcloud-grpc
namespace: production
annotations:
kubernetes.io/ingress.class: traefik
ingress.kubernetes.io/protocol: h2c
traefik.protocol: h2c
spec:
rules:
- host: grpc.test.com
http:
paths:
- path: /
backend:
serviceName: velcloud-grpc
servicePort: grpc
Edit: More information
After some debugging, I inspected the received response:
{ client_close: true,
metadata: { date: [ 'Wed, 06 Feb 2019 23:48:06 GMT' ] },
read: <Buffer 0a 04 50 4f 4e 47>,
status:
{ code: 2,
details: 'No status received',
metadata: Metadata { _internal_repr: {} } } } { code: 2,
details: 'No status received'
}
The only problem here is the status, the read content the right response once deserialized: { response: 'PONG' }
I don't know why the status is set to 2 (UNKNOWN) and not 0 (OK).

In my Traefik configuration, I use the retry middleware([retry]) and Traefik v1.7.8 have a bug:
When the retry middleware has already sent the headers, use the original headers map to be able to send trailers.
https://github.com/containous/traefik/pull/4442
I manually build the v1.7 branch with this fix and everything works again!
Thanks a lot to Containous (Damien and Julien!) for helping to debug this issue!

Related

getServerSideProps on NextJS converting the localhost to ::1

I have a NextJS project which has an index page:
pages/index.jsx
const Home = NextPage<Props> = (props) => {
...
...
...
}
export default async function getServerSideProps() {
posts = await('http://localhost:8000/posts/')
return {
props: { posts }
}
}
But the domain of the fetch request is being changed to the ipv6 address (::1) and this causes a connection refused error. (Backend server is not accepting ipv6 requests)
My question is why NextJS is doing this on getServerSideProps? (Fetch requests from frontend is not doing the same thing)
Here is some more info about my issue:
URL that trying to be fetched: http://localhost:8000/posts/?ishot=true
Options on that fetch request:
{
mode: 'cors',
cache: 'no-cache',
credentials: 'include',
headers: {},
redirect: 'follow',
method: 'GET'
}
The error that I am receiving:
error - TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:14152:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: Error: connect ECONNREFUSED ::1:8000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 8000
},
page: '/'
}

Ocelot + consul + my web api (.Net 5) via HTTPS in docker

I'm trying to use Ocelot (Api gateway) + consul + my web api (.Net 5) via HTTPS in docker;
ocelot - v17.0.0
consul - latest https://hub.docker.com/_/consul
my service - ASP.NET 5 Web Api
Trust HTTPS certificate from Windows Subsystem for Linux
source: https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-5.0&tabs=visual-studio#trust-https-certificate-from-windows-subsystem-for-linux
MY_SECRET_PROJECT_PATH\LicenseServiceWebApi> dotnet dev-certs https --clean
Cleaning HTTPS development certificates from the machine. A prompt might get displayed to confirm the removal of some of the certificates.
HTTPS development certificates successfully removed from the machine.
MY_SECRET_PROJECT_PATH\LicenseServiceWebApi> dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetdev.pfx -p <водкабалалайка>
The HTTPS developer certificate was generated successfully.
MY_SECRET_PROJECT_PATH\LicenseServiceWebApi> dotnet dev-certs https --trust
Trusting the HTTPS development certificate was requested. A confirmation prompt will be displayed if the certificate was not previously trusted. Click yes on the prompt to trust the certificate.
A valid HTTPS certificate is already present.
My docker-compose:
version: '3'
services:
license-service-web-api-01:
image: license-service-web-api
container_name: license-service-01
build:
context: .
dockerfile: Services/LicenseServiceWebApi/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:9001;http://+:9000
- ASPNETCORE_Kestrel__Certificates__Default__Password=${Kestrel_Certificate_Password}
- ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/aspnetdev.pfx
volumes:
- ${USERPROFILE}\.aspnet\https:/root/.aspnet/https/:ro
ports:
- 9000:9000
- 9001:9001
depends_on:
- consul
gateway:
image: gateway
container_name: gateway
build:
context: .
dockerfile: ApiGateway/gateway/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:5001;http://+:5000
- ASPNETCORE_Kestrel__Certificates__Default__Password=${Kestrel_Certificate_Password}
- ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/aspnetdev.pfx
volumes:
- ${USERPROFILE}\.aspnet\https:/root/.aspnet/https/:ro
ports:
- 5001:5001
- 5000:5000
depends_on:
- consul
consul:
image: consul
container_name: consul
command: agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0
environment:
- 'CONSUL_LOCAL_CONFIG= {"connect": {"enabled": true}}'
ports:
- 8500:8500
My configuration file "ocelot.json" (version without Consul)
{
"Routes": [
{
"SwaggerKey": "License Service",
"DownstreamPathTemplate": "/api/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "license-service-web-api-01",
"Port": 9000
}
],
"UpstreamHttpMethod": [ "Put", "Post", "GET" ],
"UpstreamPathTemplate": "/{everything}",
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"FileCacheOption": {
"TtlSeconds": 30
}
},
{
"DownstreamPathTemplate": "/swagger/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "license-service-web-api-01",
"Port": 9000
}
],
"UpstreamPathTemplate": "/swagger/{everything}",
"FileCacheOption": {
"TtlSeconds": 666
}
}
],
"SwaggerEndPoints": [
{
"Key": "License Service",
"Config": [
{
"Name": "License Service API",
"Version": "v1",
"Service": {
"Name": "License Service",
"Path": "/swagger/v1/swagger.json"
}
}
]
}
]
}
docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------------------------------------------
consul docker-entrypoint.sh agent ... Up 8300/tcp, 8301/tcp, 8301/udp, 8302/tcp, 8302/udp, 0.0.0.0:8500->8500/tcp, 8600/tcp, 8600/udp
gateway dotnet gateway.dll Up 443/tcp, 0.0.0.0:5000->5000/tcp, 0.0.0.0:5001->5001/tcp
license-service-01 dotnet LicenseServiceWebAp ... Up 443/tcp, 0.0.0.0:9000->9000/tcp, 0.0.0.0:9001->9001/tcp
CASE 1:
PS C:\Users\tim> curl http://localhost:9000/api/HealthCheck/GetMachineName
StatusCode : 200
StatusDescription : OK
Content : MachineName=2a429d520129
RawContent : HTTP/1.1 200 OK
PS C:\Users\tim> curl https://localhost:9001/api/HealthCheck/GetMachineName
StatusCode : 200
StatusDescription : OK
Content : MachineName=2a429d520129
RawContent : HTTP/1.1 200 OK
PS C:\Users\tim> curl http://localhost:5000/HealthCheck/GetMachineName
StatusCode : 200
StatusDescription : OK
Content : MachineName=2a429d520129
RawContent : HTTP/1.1 200 OK
PS C:\Users\tim> curl https://localhost:5001/HealthCheck/GetMachineName
StatusCode : 200
StatusDescription : OK
Content : MachineName=2a429d520129
RawContent : HTTP/1.1 200 OK
CASE 2:
I added an https redirect in my service
app.UseHttpsRedirection();
PS C:\Users\tim> curl http://localhost:9000/api/HealthCheck/GetMachineName
StatusCode : 200
StatusDescription : OK
Content : MachineName=345437c4c182
RawContent : HTTP/1.1 200 OK
PS C:\Users\tim> curl https://localhost:9001/api/HealthCheck/GetMachineName
StatusCode : 200
StatusDescription : OK
Content : MachineName=345437c4c182
RawContent : HTTP/1.1 200 OK
PS C:\Users\tim> curl http://localhost:5000/HealthCheck/GetMachineName
curl : Unable to resolve the remote name: 'license-service-web-api-01'
docker-compose logs ..
gateway | info: Ocelot.RateLimit.Middleware.ClientRateLimitMiddleware[0]
gateway | requestId: 0HM6VQAI1UTJU:00000002, previousRequestId: no previous request id, message: EndpointRateLimiting is not enabled for /api/{everything}
gateway | info: Ocelot.Authentication.Middleware.AuthenticationMiddleware[0]
gateway | requestId: 0HM6VQAI1UTJU:00000002, previousRequestId: no previous request id, message: No authentication needed for /HealthCheck/GetMachineName
gateway | info: Ocelot.Authorization.Middleware.AuthorizationMiddleware[0]
gateway | requestId: 0HM6VQAI1UTJU:00000002, previousRequestId: no previous request id, message: /api/{everything} route does not require user to be authorized
gateway | info: Ocelot.Requester.Middleware.HttpRequesterMiddleware[0]
gateway | requestId: 0HM6VQAI1UTJU:00000002, previousRequestId: no previous request id, message: 307 (Temporary Redirect) status code, request uri: http://license-service-web-api-01:9000/api/HealthCheck/GetMachineName
PS C:\Users\tim> curl https://localhost:5001/HealthCheck/GetMachineName
curl : Unable to resolve the remote name: 'license-service-web-api-01'
..The logs are the same
CASE 3
I'm changed configuration file ocelot.json on https and port 9001
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "license-service-web-api-01",
"Port": 9001
}
],
AND
removed line app.UseHttpsRedirection(); in my service
GET https://localhost:5001/WeatherForecast
502
225 ms
Warning: Unable to verify the first certificate
GET /WeatherForecast HTTP/1.1
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: 6cafa9e0-e195-4082-a7d4-daac4f58dff7
Host: localhost:5001
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
HTTP/1.1 502 Bad Gateway
Date: Fri, 05 Mar 2021 14:50:01 GMT
Server: Kestrel
Content-Length: 0
gateway | info: Ocelot.RateLimit.Middleware.ClientRateLimitMiddleware[0]
gateway | requestId: 0HM6VSNQ8J5GI:00000002, previousRequestId: no previous request id, message: EndpointRateLimiting is not enabled for /api/{everything}
gateway | info: Ocelot.Authentication.Middleware.AuthenticationMiddleware[0]
gateway | requestId: 0HM6VSNQ8J5GI:00000002, previousRequestId: no previous request id, message: No authentication needed for /WeatherForecast
gateway | info: Ocelot.Authorization.Middleware.AuthorizationMiddleware[0]
gateway | requestId: 0HM6VSNQ8J5GI:00000002, previousRequestId: no previous request id, message: /api/{everything} route does not require user to be authorized
gateway | warn: Ocelot.Responder.Middleware.ResponderMiddleware[0]
gateway | requestId: 0HM6VSNQ8J5GI:00000002, previousRequestId: no previous request id, message: Error Code: ConnectionToDownstreamServiceError Message: Error connecting to downstream service, exception: System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
gateway | ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors
gateway | at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
gateway | at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
gateway | at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
gateway | --- End of inner exception stack trace ---
gateway | at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
gateway | at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
gateway | at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
gateway | at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
gateway | at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
gateway | at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
gateway | at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)
gateway | at Ocelot.Requester.HttpClientHttpRequester.GetResponse(HttpContext httpContext) errors found in ResponderMiddleware. Setting error response for request path:/WeatherForecast, request method: GET
I have questions, maybe someone can help me, please:
Why ocelot can't call my serive over https?
How i can https enabled for Consul inside docker - compose?
you have a ssl error last case. You may 2 options for this issue
best.option you creating your own certificate and then getting it trusted by your local or remote machine.
quick option you can add this line your ocelot.json
"DangerousAcceptAnyServerCertificateValidator": true
you should add networks tag on your docker-compose file.
like below:
version: '3'
networks:
dockerapi:
driver: bridge
services:
license-service-web-api-01:
image: license-service-web-api
container_name: license-service-01
build:
context: .
dockerfile: Services/LicenseServiceWebApi/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:9001;http://+:9000
- ASPNETCORE_Kestrel__Certificates__Default__Password=${Kestrel_Certificate_Password}
- ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/aspnetdev.pfx
volumes:
- ${USERPROFILE}\.aspnet\https:/root/.aspnet/https/:ro
ports:
- 9000:9000
- 9001:9001
depends_on:
- consul
networks:
- dockerapi
gateway:
image: gateway
container_name: gateway
build:
context: .
dockerfile: ApiGateway/gateway/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:5001;http://+:5000
- ASPNETCORE_Kestrel__Certificates__Default__Password=${Kestrel_Certificate_Password}
- ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/aspnetdev.pfx
volumes:
- ${USERPROFILE}\.aspnet\https:/root/.aspnet/https/:ro
ports:
- 5001:5001
- 5000:5000
depends_on:
- consul
networks:
- dockerapi

Envoy routing based on gRPC method and paremeter

I have a Protobuf file Routing.proto used in a gRPC service. I also have an Envoy simple.yaml file.
I am trying to gRPC route match on method service_B_hello(1) where 1 is a camera_id value wrapped inside CopyImageRequest.
How can i do this route matching in Envoy with method parameter camera_id within the request ?
Routing.proto:
syntax = "proto3";
package routing;
message CopyImageRequest {
int32 camera_id = 1;
}
message CopyImageResponse {
string result = 1;
}
service RoutingService {
rpc service_A_hello(CopyImageRequest) returns (CopyImageResponse) {};
rpc service_B_hello(CopyImageRequest) returns (CopyImageResponse) {};
rpc service_C_hello(CopyImageRequest) returns (CopyImageResponse) {};
}
simple.yaml Envoy file:
routes:
- match:
prefix:"/routing.RoutingService/service_B_hello"
headers:
- name: "method"
exact_match: "service_B_hello"
- name: "camera_id"
regex_match: ^[0-3]$
- name: content-type
exact_match: application/grpc
grpc: {}
route:
auto_host_rewrite: true
cluster: grpc_stateless_service
TIA,

docker compose jest integration tests cannot make intra-container http requests RequestError: Error: getaddrinfo ENOTFOUND

I have a docker compose stack with a few containers. The two in question are an extended python:3-onbuild container (see base image here) with a falcon webserver running and a basic node:8.11-alpine container that is attempting to make post requests to the python webserver. The python webserver is making database calls to a postgres:alpine container. This is a simplified version of my docker-compose.yml file:
version: '3.6'
services:
app: # python:3-onbuild
ports:
- 5000
build:
context: ../../
dockerfile: infra/docker/app.Dockerfile
lambda: # node:8.11-alpine
ports:
- 10000
build:
context: ../../
dockerfile: infra/docker/lambda.Dockerfile
depends_on:
- app
db: # postgres:alpine
ports:
- 5432:5432
build:
context: ../../
dockerfile: infra/docker/db.Dockerfile
I have a suite of integration tests I'm trying to pass. When I run the tests with an endpoint in the outside world (https python server running the same code as the app service) all of the tests pass. The problem arises when I try to make these requests against the app service from within my docker-compose stack, specifically from the lambda service to the app service.
I don't think it is a timing issue. In the beforeAll function of my jest suite, I poll the python server for 100 seconds, once every 10 seconds like this:
In my jest test
beforeAll(async () => {
const endpointUrl = getEndpointUrl();
const status = await checkStatus(endpointUrl, 10);
// NOTE: never reaches this line, starts tests before 5-minute timeout
console.log(`[integration.test]: status = ${status}`);
}, 5 * 60 * 1000); // 5-minute timeout for async function
Where checkStatus() is defined
/**
* Checks the status of the backend every 10 seconds, n times
* #param {string} endpointUrl
* #param {number} n
*/
export function checkStatus(endpointUrl: string, n: number): Promise<string> {
console.log(`[lib][checkStatus]: before timeout date = ${Date()}`);
return new Promise<string>((resolve, reject) => {
checkStatusHelper(endpointUrl, n, resolve, reject);
});
}
function checkStatusHelper(endpointUrl, n, resolve, reject): void {
if (n === 0) reject();
setTimeout(() => {
console.log(`[lib][checkStatus]: after timeout date ${n} = ${Date()}`);
rp.get(`${endpointUrl}/status`)
.then(res => {
console.log(`[lib][checkStatus]: after request date = ${Date()}`);
console.log(`[lib][checkStatus]: res = ${res}`);
resolve('success');
})
.catch(err => {
console.log(`[lib][checkStatus]: err = ${err}`);
checkStatusHelper(endpointUrl, n - 1, resolve, reject);
});
}, 10 * 1000);
}
I get output like the following (with request-promise-native):
console.log src/lib.ts:30
[lib][checkStatus]: before timeout date = Fri May 11 2018 01:54:10 GMT+0000 (UTC)
console.log src/lib.ts:39
[lib][checkStatus]: after timeout date 10 = Fri May 11 2018 01:54:20 GMT+0000 (UTC)
console.log src/lib.ts:47
[lib][checkStatus]: err = RequestError: Error: getaddrinfo ENOTFOUND app app:5000
console.log src/lib.ts:39
[lib][checkStatus]: after timeout date 9 = Fri May 11 2018 01:54:31 GMT+0000 (UTC)
console.log src/lib.ts:47
[lib][checkStatus]: err = RequestError: Error: getaddrinfo ENOTFOUND app app:5000
# etc ...
And similar output with axios instead of request-promise-native
console.log src/lib.ts:30
[lib][checkStatus]: before timeout date = Fri May 11 2018 01:56:57 GMT+0000 (UTC)
console.log src/lib.ts:39
[lib][checkStatus]: after timeout date 10 = Fri May 11 2018 01:57:07 GMT+0000 (UTC)
console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Error: getaddrinfo ENOTFOUND app app:5000
at Object.dispatchError (/Halloo/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
at Request.client.on.err (/Halloo/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:676:20)
at emitOne (events.js:121:20)
at Request.emit (events.js:211:7)
at Request.onRequestError (/Halloo/node_modules/request/request.js:878:8)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7) undefined
console.log src/lib.ts:47
[lib][checkStatus]: err = Error: Network Error
console.log src/lib.ts:39
[lib][checkStatus]: after timeout date 9 = Fri May 11 2018 01:57:18 GMT+0000 (UTC)
console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Error: getaddrinfo ENOTFOUND app app:5000
at Object.dispatchError (/Halloo/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
at Request.client.on.err (/Halloo/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:676:20)
at emitOne (events.js:121:20)
at Request.emit (events.js:211:7)
at Request.onRequestError (/Halloo/node_modules/request/request.js:878:8)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7) undefined
console.log src/lib.ts:47
[lib][checkStatus]: err = Error: Network Error
# etc ...
I also don't think it is not a networking issue. If I comment out my test step and let the lambda service spin up normally, I can ssh into the lambda container and test the connection using axios or request-promise-native. This /status endpoint simply returns the all the table names in my database to ensure the database container is also running properly. This works almost instantly, and far before 100 seconds
$ node
> const axios = require('axios')
undefined
> axios.get('http://app:5000/status').then(res => console.log(res.data));
Promise {
<pending>,
domain:
Domain {
domain: null,
_events: { error: [Function: debugDomainError] },
_eventsCount: 1,
_maxListeners: undefined,
members: [] } }
> [ [ 'table0' ],
[ 'table1' ],
[ 'table2' ],
[ 'table3' ],
[ 'table4' ],
[ 'table5' ] ]
I thought maybe I can't use jest for these purposes, but I feel like I can because everything works flawlessly when I change the url to my production https endpoint running in aws and comment out the beforeAll() step in my jest suite.
It ended up being a problem with my jest configuration
The default environment in Jest is a browser-like environment through jsdom. If you are building a node service, you can use the node option to use a node-like environment instead.
To fix this I had to add this in my jest.config.js file:
{
// ...
testEnvironment: 'node'
// ...
}
Source: https://github.com/axios/axios/issues/1418

onPush() function not getting hit after push from controller using ZeroMQ in Guinness of Symfony/Websocket bundle in symfony2

Config.yml
gos_web_socket:
topics:
- #app.real_time.subscribe
- #app.real_time.push
server:
port: 8000 #The port the socket server will listen on
host: localhost #The host ip to bind to
router:
resources:
- #AppBundle/Resources/config/pubsub/routing.yml
client:
firewall: main #can be an array of firewalls
session_handler: #session.handler.pdo
pushers:
zmq:
default: true
host: 127.0.0.1
port: 8888
persistent: true
protocol: tcp
pubsub/routing.yml
real_time_push:
channel: all/user
handler:
callback: 'app.real_time.push' #related to the getName() of your topic
services.yml
app.real_time.subscribe:
class: AppBundle\RealTime\Subscribe
arguments: [ #gos_web_socket.websocket.client_manipulator ]
app.real_time.push:
class: AppBundle\RealTime\Push
arguments: [ #gos_web_socket.websocket.client_manipulator ]
The following function is getting hit when client subscribes on this topic. I can see the text in the console.
Subscribe Class onSubscribe() : Subscribe.php
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
var_dump("This user is subscribed");
}
But when pushed via zmq from controller the onPush() function never got hit. I have already implemented TopicInterdace and PushableTopicInterface in Push.php.
Push Class onPush() : Push.php
public function onPush(Topic $topic, WampRequest $request, $data, $provider)
{
var_dump("Helloooooooooooooooooo0000000000");
}
Please can any one tell me where did I do wrong. Thanks in advance. Here is the controller
$pusher = $this->container->get('gos_web_socket.zmq.pusher');
//push(data, route_name, route_arguments)
$pusher->push(['my_data' => 'data'], 'real_time_push', ['username' => 'sujit']);

Resources