I am using the PHP library php-amqplib with Amazon MQ Rabbit
When I create a new AMQPSSLConnection object with like the following:
$this->connection = new AMQPSSLConnection(
$params->get('rabbit_host'),
$params->get('rabbit_port'),
$params->get('rabbit_username'),
$params->get('rabbit_password'),
$params->get('rabbit_vhost'),
[
'verify_peer' => false
],
[
'heartbeat' => 20,
'connection_timeout' => 99999,
'read_write_timeout' => 99999,
'channel_rpc_timeout' => 99999
]
);
I get the error:
[PhpAmqpLib\Exception\AMQPTimeoutException] The connection timed out after 0.33181881904602 sec while awaiting incoming data
after 60 seconds of the script running. I've tried various values for heartbeat and timeout settings but none keep the script running
Edit - This issue was caused by me passing in a timeout value to $channel->wait(). Once I increased the 3rd parameter value (timeout), the issue was resolved
This issue was caused by me passing in a timeout value to $channel->wait(). Once I increased the 3rd parameter value (timeout), the issue was resolved
Related
I am uploading a large file from my local system or an remote_url to google bucket. However everytime I am getting the below error.
/usr/local/lib/ruby/3.0.0/openssl/buffering.rb:345:in `syswrite': execution expired (Google::Apis::TransmissionError)
/usr/local/lib/ruby/3.0.0/openssl/buffering.rb:345:in `syswrite': execution expired (HTTPClient::SendTimeoutError)
I am using carrierwave initializer to define configuration of my google service account and its details. Please suggest if there is any configuration I am missing or if I add to increase the timeout or retries.
My Carrierwave initializer:
begin
CarrierWave.configure do |config|
config.fog_provider = 'fog/google'
config.fog_credentials = {
provider: 'Google',
google_project: '{project name}',
#google_json_key_string: Rails.application.secrets.google_cloud_storage_credential_content
google_json_key_location: '{My json key-file location}'
}
config.fog_attributes = {
expires: 600000,
open_timeout_sec: 600000,
send_timeout_sec: 600000,
read_timeout_sec: 600000,
fog_authenticated_url_expiration: 600000
}
config.fog_authenticated_url_expiration = 600000
config.fog_directory = 'test-bucket'
end
#
rescue => error
puts error.message
end
This might have to do with the duration of time between when the connection and initialized and when it actually gets used. Adding: persistent: false to the fog_credentials should make it create a new connection for each request. This is a bit less performant, but it should at least work consistently, unlike what you appear to be running into presently.
Using #golevelup/nestjs-rabbitmq I tried the connection manager to not wait for a connection. According to the readme it can handle reconnections and wait for a connection without crashing the app. However, when I use the connectionInitOptions as stated and set wait to false, I get a connection error. When I don't use it (default behavior setting wait to true) , it connects to the RabbitMQ server. Below are examples importing the RabbitMQModule in a NestJS module.
This works and connects to the RabbitMQ server
RabbitMQModule.forRoot(RabbitMQModule, {
exchanges: [{ type: 'topic', name: 'main' }],
uri: 'amqp://guest:guest#localhost:5672',
}
This doesn't work and won't connect
RabbitMQModule.forRoot(RabbitMQModule, {
exchanges: [{ type: 'topic', name: 'main' }],
uri: 'amqp://guest:guest#localhost:5672',
connectionInitOptions: {
wait: false,
},
With the second option I get the following error:
Error: AMQP connection is not available
at AmqpConnection.publish (/home/xxx/node_modules/#golevelup/nestjs-rabbitmq/src/amqp/connection.ts:424:13)
at BootstrapService.onApplicationBootstrap (/home/xxx/src/bootstrap/bootstrap.service.ts:20:25)
at MapIterator.iteratee (/home/xxx/node_modules/#nestjs/core/hooks/on-app-bootstrap.hook.js:22:43)
at MapIterator.next (/home/xxx/node_modules/iterare/src/map.ts:9:39)
at IteratorWithOperators.next (/home/xxx/node_modules/iterare/src/iterate.ts:19:28)
at Function.from (<anonymous>)
at IteratorWithOperators.toArray (/home/xxx/node_modules/iterare/src/iterate.ts:227:22)
at callOperator (/home/xxx/node_modules/#nestjs/core/hooks/on-app-bootstrap.hook.js:23:10)
at callModuleBootstrapHook (/home/xxx/node_modules/#nestjs/core/hooks/on-app-bootstrap.hook.js:43:23)
at NestApplication.callBootstrapHook (/home/xxx/node_modules/#nestjs/core/nest-application-context.js:199:55)
at NestApplication.init (/home/xxx/node_modules/#nestjs/core/nest-application.js:98:9)
at NestApplication.listen (/home/xxx/node_modules/#nestjs/core/nest-application.js:155:33)
at bootstrap (/home/xxx/src/main.ts:12:3)
The last line (main.ts:12:3) is the app.listen(3000) statement.
There are other options you can set with the connectionInitOptions (reject and timeout) and I've tried the combinations but still no connection.
RabbitMQ is running in a docker container on Linux but that should be no problem. I posted the same question on NestJS discord but got no reply, so hopefully someone on SO has an idea.
Any idea what could be the cause?
Found the problem, I was using the connection in a onApplicationBootstrap method and then the connection is apparently not present yet.
you can wait for connection asynchronously 'onApplicationBootstrap':
or on :
async onModuleInit() {
await this.amqpConnection.managedChannel.waitForConnect(async () => {
await this.assertQueueAndBindToExchange(
transferRequestQueueName,
transferRequestExchangeName,
createdRoutingKey
);
Hey I've created a test that is passing locally wihtout a problem but failing 50% of the time during CI tests.
it("Check if scroll is working on list", { retries: 3 }, () => {
cy.server()
cy.intercept('GET','**/api/**', {
statusCode: 200
}).as('loadMoreAbstracts')
cy.get('[data-cy=VirtualScroll]', { timeout: 15000 }).scrollTo("bottom").then(() => {
cy.wait('#loadMoreAbstracts', { timeout: 15000 })
cy.get('[data-cy=VirtualScroll]').invoke('scrollTop').should('be.gt', 0)
})
cy.get('[data-cy=VirtualScroll]', { timeout: 15000 }).scrollTo("bottom")
})
Could anybody tell me what can be wrong with this test and why its working locally but failing most of the time on CI? Other tests that require listening to request are 100% passing on CI, only this one has problem somehow but I cant figure it out. Locally it never fails.
Error I am getting:
Check if scroll is working on list:
CypressError: Timed out retrying: `cy.wait()` timed out waiting `15000ms` for the 1st request to the route: `loadMoreAbstracts`. No request ever occurred.
I am trying to implement the Cro Service from the Cro getting started documentation. It compiled fine but when I tried to access the link using browser, it shows cannot reach the site and throws "Connection reset by peer" error with no other details. The code is below:
use Cro::HTTP::Log::File;
use Cro::HTTP::Server;
use Routes;
my Cro::Service $http = Cro::HTTP::Server.new(
http => <1.1>,
host => '0.0.0.0',
port => 3001,
application => routes(),
after => [
Cro::HTTP::Log::File.new( logs => $*OUT, errors => $*ERR)
]
);
$http.start;
say "Listening at http://server:3001";
react {
whenever signal(SIGINT) {
say "Shutting down...";
$http.stop;
done;
}
}
Is there a way to troubleshot this so that I can identify what the actual error is?
Where in the configuration file do I set the connection timeout for Redis?
I know there is a timeout setting in the config file, but that only applies for idle connections. I want the timeout to apply when I want to read from redis. I want it to time out only after N seconds, rather than the default.
For anyone who is still looking for this, on a redis connnection string you can specify connectTimeout like below.
<add key="RedisConnectionString" value="your-redis-server,abortConnect=false,connectTimeout=1000,ssl=false,,password=your-password" />
On console of redis set this configuration
config set timeout 300
You basically need a read-timeout
This will be a client side property
Mention this in your application.
I'll examplify for Laravel framework of PHP
specify it at database.php file ('read_timeout' => 60)
'redis' => [
'client' => 'predis',
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
'read_timeout' => 60,
],
],
];