|
Hospedagem de Imagens no S3
|
|
2
|
534
|
10 de Novembro de 2023
|
|
Migrar uploads antigos para o Minio
|
|
4
|
735
|
20 de Dezembro de 2019
|
|
Docker não está usando um driver de armazenamento suportado
|
|
5
|
1193
|
8 de Julho de 2019
|
|
Como posso hospedar mais de 1 fórum Discourse em 1 VPS?
|
|
4
|
1304
|
7 de Agosto de 2020
|
|
Plugin não está sendo instalado
|
|
7
|
579
|
15 de Fevereiro de 2023
|
|
Instruções de hospedagem confusas - é possível instalar em webhosting alugado sem sudo?
|
|
4
|
1302
|
14 de Setembro de 2022
|
|
Clicar em link de e-mail do sistema redireciona para página em branco
|
|
3
|
818
|
7 de Dezembro de 2020
|
|
Atualização para o Failure Discourse 2.8
|
|
7
|
1026
|
26 de Fevereiro de 2022
|
|
Installation issues on Scaleway
|
|
3
|
1450
|
28 de Julho de 2017
|
|
Configurar cerbot com app.yml?
|
|
4
|
729
|
6 de Janeiro de 2022
|
|
Três sites em uma única configuração
|
|
4
|
1294
|
26 de Maio de 2019
|
|
Mais de um site como contêiner diferente rodando no mesmo servidor do
|
|
3
|
813
|
24 de Dezembro de 2019
|
|
Can I host a discourse forum on 000 web host?
|
|
6
|
3454
|
26 de Novembro de 2015
|
|
Posso usar uma versão posterior do Postgres do que o Discourse?
|
|
5
|
1179
|
20 de Janeiro de 2022
|
|
Out-migration from Communiteq?
|
|
4
|
1290
|
12 de Março de 2015
|
|
Erro "Net::ReadTimeout com # This is a common error in Ruby on Rails applications, specifically when dealing with network requests. Let's break down what it means and how to fix it.
**Understanding the Error:**
* **`Net::ReadTimeout`**: This is a standard Ruby exception that indicates a network socket has timed out while waiting for a read operation to complete. In simpler terms, your application tried to read data from a remote server, but the server didn't respond within the expected timeframe.
* **`#<TCPSocket:(closed)>`**: This part tells you that the connection being used for the read operation was a `TCPSocket` and it was already closed. This means the connection was either closed by the remote server (perhaps due to inactivity, an error on their end, or a network issue) or by your application itself before the read operation could complete.
**Common Causes:**
1. **Slow or Unresponsive Server:** The most frequent cause is that the external service or API your Rails app is trying to communicate with is slow to respond, overloaded, or temporarily unavailable.
2. **Network Issues:** Intermittent network problems between your server and the external service can cause read timeouts. This could be on your end, the external service's end, or somewhere in between (like a firewall or proxy).
3. **Long-Running Requests:** If your application is making a request that takes a very long time to process on the server side, the connection might time out before the response is fully received.
4. **Incorrect Configuration:** Sometimes, the timeout settings in your application or in network infrastructure (like load balancers or firewalls) might be too short for the expected response time of the external service.
5. **Connection Closed Prematurely:** Your application might be closing the connection before the response is fully read, although this is less common for standard HTTP libraries unless there's custom connection management involved.
**How to Fix It:**
Here's a systematic approach to troubleshooting and resolving this error:
1. **Increase Timeout Settings:**
* **HTTP Client Libraries:** If you're using libraries like `Net::HTTP` (which is often used by default or by other gems), you can explicitly set the read timeout. For example:
```ruby
require 'net/http'
require 'uri'
uri = URI.parse('http://example.com/slow_endpoint')
http = Net::HTTP.new(uri.host, uri.port)
http.read_timeout = 300 # Set timeout to 300 seconds (5 minutes)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
```
* **Gems like Faraday:** If you're using Faraday, you can configure timeouts like this:
```ruby
Faraday.new(url: 'http://example.com') do |faraday|
faraday.options.timeout = 10 # seconds
faraday.options.open_timeout = 5 # seconds
# ... other configurations
end
```
* **Other Gems:** Check the documentation for the specific HTTP client gem you are using (e.g., `httparty`, `rest-client`) for how to configure timeouts.
2. **Check the External Service:**
* **Status Page:** Look for a status page or status updates from the service you are trying to connect to. They might be experiencing issues.
* **API Documentation:** Review the API documentation for expected response times and any rate limits that might be causing throttling.
* **Contact Support:** If the service is consistently slow or unresponsive, reach out to their support team.
3. **Investigate Network Connectivity:**
* **`ping` and `traceroute`:** From your server, try to `ping` the host of the external service and use `traceroute` (or `mtr`) to identify any network latency or packet loss.
* **Firewalls/Proxies:** Ensure that no firewalls or proxy servers are interfering with or have overly aggressive timeout settings for the connection.
4. **Implement Retries and Circuit Breakers:**
* **Retries:** For transient network issues or slow responses, implement a retry mechanism. Be careful not to retry too aggressively, as this can worsen the problem for the external service.
* **Circuit Breaker Pattern:** For services that are consistently failing, consider implementing a circuit breaker pattern to stop making requests to the failing service for a period, preventing your application from being overwhelmed.
5. **Asynchronous Processing:**
* If the external request is inherently long-running, consider performing it asynchronously using background job systems like Sidekiq, Delayed Job, or Resque. This prevents your web requests from timing out and improves user experience.
6. **Review Your Code:**
* Ensure you aren't accidentally closing the connection prematurely in your code, especially if you have custom network handling.
**Example using `Net::HTTP` in a Rails context:**
If you have a service object or a model method making the call:
```ruby
# app/services/external_api_service.rb
require 'net/http'
require 'uri'
class ExternalApiService
def fetch_data(resource_path)
uri = URI.parse("https://api.example.com/#{resource_path}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true # If the API uses HTTPS
http.read_timeout = 120 # Set a reasonable timeout, e.g., 120 seconds
http.open_timeout = 10 # Set a shorter timeout for establishing the connection
request = Net::HTTP::Get.new(uri.request_uri)
# Add any necessary headers, e.g., authentication tokens
# request['Authorization'] = "Bearer YOUR_API_KEY"
begin
response = http.request(request)
if response.is_a?(Net::HTTPSuccess)
JSON.parse(response.body)
else
# Handle non-success responses (e.g., 4xx, 5xx errors)
Rails.logger.error "API Error: #{response.code} - #{response.message}"
nil
end
rescue Net::ReadTimeout => e
Rails.logger.error "API Read Timeout Error: #{e.message}"
nil
rescue Net::OpenTimeout => e
Rails.logger.error "API Open Timeout Error: #{e.message}"
nil
rescue StandardError => e
Rails.logger.error "Unexpected API Error: #{e.message}"
nil
end
end
end
```
**In summary:** The `Net::ReadTimeout` with `TCPSocket:(closed)` error usually points to a problem with the external service's responsiveness or network conditions. The most common solution is to increase the timeout values in your HTTP client configuration, but it's also crucial to investigate the external service and network path for underlying issues.
|
|
8
|
3039
|
28 de Janeiro de 2024
|
|
How can I update nginx.conf without resetting it on rebuild?
|
|
5
|
1176
|
15 de Março de 2022
|
|
DISCOURSE_ENABLE_CORS not impacting Nginx config
|
|
3
|
1440
|
13 de Outubro de 2015
|
|
Problema ao atualizar para 2.5.0.beta4
|
|
7
|
1016
|
11 de Maio de 2020
|
|
Discourse is loading pictures from the wrong domain
|
|
5
|
1172
|
16 de Dezembro de 2015
|
|
Installing Discourse on a Linux Web Server @ one.com
|
|
3
|
1432
|
23 de Setembro de 2015
|
|
Suggestion: look at openshift free tier
|
|
0
|
1609
|
17 de Março de 2016
|
|
Problema PG::UniqueViolation durante o upgrade para 3.1.0.beta4
|
|
6
|
608
|
19 de Maio de 2023
|
|
Rebake falha ao alterar apenas o nome do subdomínio
|
|
6
|
1081
|
14 de Abril de 2023
|
|
Confusion about the email server before installing discourse
|
|
4
|
1275
|
21 de Fevereiro de 2017
|
|
Bad gateway when trying to use SSL
|
|
2
|
1645
|
8 de Junho de 2024
|
|
Falha no backup do Pg_dump para pgsql remoto - diferenças de porta e versão; quais opções existem?
|
|
6
|
3402
|
20 de Agosto de 2022
|
|
Reconstrução falhou, procure ajuda
|
|
3
|
253
|
30 de Abril de 2024
|
|
Reconstrução Falhou, por favor ajude!
|
|
7
|
1005
|
28 de Setembro de 2022
|
|
Avatars in an offline install
|
|
2
|
920
|
24 de Julho de 2016
|
|
A instalação do Discourse para desenvolvimento está falhando
|
|
3
|
796
|
10 de Abril de 2023
|
|
443 address already in use? Letencrypt
|
|
6
|
3378
|
6 de Janeiro de 2018
|
|
Question about configuring email on shared hosting
|
|
6
|
1895
|
20 de Maio de 2015
|
|
Existe alguma forma mais rápida de reconstruir o site?
|
|
4
|
398
|
30 de Março de 2024
|
|
Falha ao reconstruir o app
|
|
6
|
1060
|
4 de Março de 2020
|
|
É necessário selecionar o Discourse?
|
|
4
|
1254
|
3 de Maio de 2021
|
|
Gerando chaves do LetsEncrypt a partir de trás do nginx
|
|
3
|
1401
|
28 de Setembro de 2018
|
|
Instale o Discourse no CentOS junto com o Apache já instalado e o DirectAdmin
|
|
2
|
1617
|
19 de Setembro de 2018
|
|
Pergunta sobre o uso da versão Open-Source do Discourse
|
|
1
|
626
|
12 de Junho de 2020
|
|
Documentos recomendados para instalação do Discourse CentOS 7.7?
|
|
4
|
703
|
12 de Janeiro de 2020
|
|
Não é possível usar ./launcher para entrar no aplicativo
|
|
7
|
988
|
4 de Setembro de 2022
|
|
Instalei o Discourse em um subdomínio via DigitalOcean Droplet. Como adicionar node/Vue.js no domínio principal?
|
|
5
|
640
|
25 de Abril de 2023
|
|
Rebake aborta com mensagem de erro
|
|
5
|
1138
|
12 de Março de 2022
|
|
Site NÃO Exibindo!
|
|
4
|
700
|
16 de Dezembro de 2022
|
|
Provedor de VPS que não está bloqueado na Rússia?
|
|
6
|
1867
|
10 de Abril de 2019
|
|
Falha na atualização, "FAILED TO BOOTSTRAP", erro 137
|
|
6
|
1046
|
11 de Novembro de 2022
|
|
Www funciona -- domínio raiz apex não funciona
|
|
6
|
588
|
27 de Abril de 2024
|
|
Executando Discourse com pg_bouncer e um banco de dados separado
|
|
2
|
891
|
20 de Setembro de 2020
|
|
Problemas sérios de desempenho!
|
|
2
|
501
|
26 de Maio de 2021
|
|
Metadados da nuvem potencialmente expostos - Teste de penetração
|
|
4
|
1226
|
2 de Novembro de 2023
|