Going through Daniel Kehoe's Learn Ruby on Rails book. Have tutorial successfully posting to MailChimp list in development. Pushed to heroku, and tested. When submitting email address to join newsletter, get error in logs -
2016-09-08T19:54:14.872341+00:00 app[web.1]: Completed 500 Internal
Server Error in 12ms (ActiveRecord: 0.0ms)
2016-09-08T19:54:14.872876+00:00 app[web.1]:
2016-09-08T19:54:14.872878+00:00 app[web.1]: Gibbon::MailChimpError
(Failed to open TCP connection to key.api.mailchimp.com:443
(getaddrinfo: Name or service not known) #title=nil, #detail=nil,
#body=nil, #raw_body=nil, #status_code=nil):
2016-09-08T19:54:14.872879+00:00 app[web.1]:
app/models/visitor.rb:10:in subscribe'
2016-09-08T19:54:14.872880+00:00 app[web.1]:
app/controllers/visitors_controller.rb:10:in `create'
Suggestions on how to troubleshoot would be appreciated.
Related
Some log from heroku:
2022-10-16T05:19:03.088622+00:00 heroku[router]: at=error code=H15 desc="Idle connection" method=GET path="/api/v1/content/ws/RgPx8znal7AJb
2022-10-16T05:19:03.065493+00:00 app[web.1]: time="2022-10-16T05:19:03Z" level=info msg="error - on read: websocket: close 1006 (abnormal closure): unexpected EOF"
2022-10-16T05:20:57.758379+00:00 app[web.1]: time="2022-10-16T05:20:57Z" level=info msg="cleanup client, id = 'wscid-ee670cc5-4100-49d6-9857-8284d93a6d33'"
2022-10-16T05:20:57.758505+00:00 app[web.1]: time="2022-10-16T05:20:57Z" level=info msg="close msg received: &{418 close}"
Seems heroku will kill the websocket connection if there is no msg for a while.
Questions:
If I want to keep the connection alive:
Should I send ping/pong msg to keep the connection alive?
Or, there are other ways to do that (e.g upgrade my account paid plan?) ?
BTW:
If I deploy it on bare linux, the websocket connection never auto close.
I do have auto connect from the client side, but that's even more expensive, and not good for user experience I think.
Update
Seems heroku router will kill the idle connection after 55 seconds.
I'm trying to deploy a Scala Play project on Heroku via Heroku CLI.
It works well, but when the server tries to start it crashes with the following error:
2021-08-17T16:47:52.333689+00:00 app[web.1]: at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
2021-08-17T16:47:52.333713+00:00 app[web.1]: at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
2021-08-17T16:47:52.333753+00:00 app[web.1]: at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
2021-08-17T16:47:52.333762+00:00 app[web.1]: at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168)
2021-08-17T16:47:52.333789+00:00 app[web.1]: at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39)
2021-08-17T16:47:52.333813+00:00 app[web.1]: at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62)
2021-08-17T16:47:52.333838+00:00 app[web.1]: at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:213)
2021-08-17T16:47:52.333867+00:00 app[web.1]: at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184)
2021-08-17T16:47:52.333893+00:00 app[web.1]: at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:111)
2021-08-17T16:47:52.333919+00:00 app[web.1]: at com.google.inject.Guice.createInjector(Guice.java:87)
2021-08-17T16:47:52.333942+00:00 app[web.1]: at com.google.inject.Guice.createInjector(Guice.java:78)
2021-08-17T16:47:52.333968+00:00 app[web.1]: at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:200)
2021-08-17T16:47:52.333993+00:00 app[web.1]: at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:155)
2021-08-17T16:47:52.334018+00:00 app[web.1]: at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
2021-08-17T16:47:52.334042+00:00 app[web.1]: at play.core.server.ProdServerStart$.start(ProdServerStart.scala:53)
2021-08-17T16:47:52.334076+00:00 app[web.1]: at play.core.server.ProdServerStart$.main(ProdServerStart.scala:29)
2021-08-17T16:47:52.334102+00:00 app[web.1]: at play.core.server.ProdServerStart.main(ProdServerStart.scala)
2021-08-17T16:47:52.408221+00:00 heroku[web.1]: Process exited with status 255
2021-08-17T16:47:52.471552+00:00 heroku[web.1]: State changed from starting to crashed
2021-08-17T16:47:52.490499+00:00 heroku[web.1]: State changed from crashed to starting
2021-08-17T16:47:58.797308+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/bionplaydatawarehouse -Dhttp.port=${PORT}`
2021-08-17T16:48:01.183756+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2021-08-17T16:48:01.398386+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2021-08-17T16:48:06.203049+00:00 app[web.1]: WARNING: An illegal reflective access operation has occurred
2021-08-17T16:48:06.203069+00:00 app[web.1]: WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/app/target/universal/stage/lib/com.google.inject.guice-4.2.3.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
2021-08-17T16:48:06.203069+00:00 app[web.1]: WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
2021-08-17T16:48:06.203070+00:00 app[web.1]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2021-08-17T16:48:06.203076+00:00 app[web.1]: WARNING: All illegal access operations will be denied in a future release
2021-08-17T16:48:15.071607+00:00 app[web.1]: Oops, cannot start the server.
The projet parameters are:
Play 2.8.8
Scala 2.13.5
SBT 1.5.0
Java 11
The project is based on an IntelliJ Ultimate Template.
The Heroku Procfile looks like this:
web: target/universal/stage/bin/bionplaydatawarehouse -Dhttp.port=${PORT}
The system.properties file looks like this to overwrite the default Java 8 Version:
java.runtime.version=11
When I change the Java Version the compilation crashes with a Class Cast Exception.
It seems that the Guice DI is the problem or some configuration parameter is missing for the Heroku production invironment because locally the projects works well.
I got it!
You need to add the -Dplay.http.secret.key argument which value must match your appliaction secret.
Unfortunately this was not part auf the documetation
web: target/universal/stage/bin/myProject -Dhttp.port=${PORT}
-Dplay.http.secret.key='mySecret'
I tried to deploy SpringBoot app generated by JHipster to Heroku, but it is failed because this error, I used JHipster way to deploy my app https://www.jhipster.tech/heroku/ , any ideas ? :
2018-04-06T21:28:57.412612+00:00 app[web.1]: 21:28:57.412 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
2018-04-06T21:28:57.412615+00:00 app[web.1]: java.lang.IllegalStateException: Failed to load property source from location 'classpath:/config/application-prod.yml'
2018-04-06T21:28:57.412617+00:00 app[web.1]: at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:476)
2018-04-06T21:28:57.412618+00:00 app[web.1]: at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:450)
2018-04-06T21:28:57.412619+00:00 app[web.1]: at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:386)
2018-04-06T21:28:57.412620+00:00 app[web.1]: at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:225)
2018-04-06T21:28:57.412621+00:00 app[web.1]: at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:195)
2018-04-06T21:28:57.412626+00:00 app[web.1]: at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
2018-04-06T21:28:57.412627+00:00 app[web.1]: at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
2018-04-06T21:28:57.412628+00:00 app[web.1]: at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
I use rails 5 with actioncable on heroku and i have this error only in production
WebSocket connection to 'wss://adham-chatty.heroku.com/cable' failed: WebSocket opening handshake was canceled
i think because of puma
2016-01-21T23:33:56.372977+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
2016-01-21T23:33:57.651242+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-01-21T23:33:58.721808+00:00 app[web.1]: [3] - Gracefully shutting down workers...
2016-01-21T23:33:58.873303+00:00 app[web.1]: [3] === puma shutdown: 2016-01-21 23:33:58 +0000 ===
2016-01-21T23:33:58.873305+00:00 app[web.1]: [3] - Goodbye!
2016-01-21T23:33:58.910391+00:00 app[web.1]: [3] Puma starting in cluster mode...
2016-01-21T23:33:58.910405+00:00 app[web.1]: [3] * Version 2.15.3 (ruby 2.2.3-p173), codename: Autumn Arbor Airbrush
2016-01-21T23:33:58.910407+00:00 app[web.1]: [3] * Min threads: 5, max threads: 5
2016-01-21T23:33:58.910409+00:00 app[web.1]: [3] * Environment: production
2016-01-21T23:33:58.910429+00:00 app[web.1]: [3] * Process workers: 2
2016-01-21T23:33:58.910453+00:00 app[web.1]: [3] * Preloading application
2016-01-21T23:33:59.632680+00:00 heroku[web.1]: Process exited with status 0
I just spent an evening and got my rails 5 ActionCable app working wonderfully on Heroku. I wrote up what I learned after going through a lot of hoops here: http://www.whodya.com/posts/19632. What I'd guess from looking at your error message above is, ahem, exactly the same problem I had for a bit. You're trying to use wss: to connect, but this only works if you're using SSL/HTTPS on your server. Try ws: instead, until you get HTTPS up and running. Again, my write-up is here (http://www.whodya.com/posts/19632), with my config/settings/etc.
-John
What does Heroku mean by app[web.1] and by <main>:48?
I have a crash that happens only on Heroku and not on my computer, I'm trying to identify the precise line causing the crash. These are the logs
2012-10-08T21:31:49+00:00 app[web.1]: <main>:48:in `method_missing': wrong number of arguments (1 for 2) (ArgumentError)
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/server.rb:104:in `block in initialize'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `load'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/server.rb:104:in `==='
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `<main>'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/server.rb:102:in `initialize'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/thin.rb:9:in `new'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/thin.rb:9:in `run'
2012-10-08T21:31:49+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/server.rb:102:in `each'
2012-10-08T21:31:50+00:00 heroku[web.1]: Process exited with status 1
2012-10-08T21:31:50+00:00 heroku[web.1]: State changed from starting to crashed
2012-10-08T21:31:52+00:00 heroku[router]: Error H10 (App crashed) -> GET placeboxy.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
Is the crash in my code or in the web server Thin or elsewhere?
Edit I changed the Procfile to run the server unicorn on Heroku and the crashed stopped. No error with puma either. Any ideas? Is Thin to fault?
The app[web.1] is a tag that heroku adds to your log to mark which process is emitting the log, as all the logs are collected in a central place, you can still filter a single process and parse the process log.
The <main>:48: part means the file/line where the execution has been stopped because of the exception. In this case (<main>) it's the main script that's being run. You won't find your error there, probably. You have to search in the backtrace for the part of your code that is failing, look for something that's not an external library, nor core ruby. The backtrace you show is of no help, normally the error is much lower in the stack trace.