How to connect a device to a Rails server via TCP? - ruby-on-rails

let me explain what I've already completed and what is needed to be done.
What's I've done
Rails server with PG database that returns some data to a user from DB via GET request.
What's needs to be completed
I need to connect the device to this server via TCP. The manufacturer of the device asks me to provide the server address and the port, so he can configure the device to send some messages to the port provided. This messages should be recorded to DB (this part is not important, just to let you know the flow I'm trying to achieve) and then a user can get those messages by GET request mentioned above.
The question
How to set up the Rails server to accept TCP messages from the device to a specified port? How to handle those messages? E.g. the simplest: how to print the message received?
Is it even possible with Rails? If you have a better option on how to achieve the flow mentioned above, please share it.
I'd appreciate some help with code or links.

Just start your rails server with command rails s -b 0.0.0.0
this will bind your public IP with your server so that you can connect with other devices to your rails server.
for example your IP is 192.168.64.40 so, after this command you can do like 192.168.64.40:3000 in to other device's browser so that they can connect to your rails server

Related

Connecting using SnowSQL denied 403 error

I am trying to configure JDBC but kept getting the same error I am getting using snowsql:
250001 (08001): Failed to connect to DB. Verify the account name is correct: JG3409.canada-central.azure.snowflakecomputing.com:443. 000403: 403: HTTP 403: Forbidden
If the error message is unclear, enable logging using -o log_level=DEBUG and see the log to find out the cause. Contact support for further help.
Goodbye!
I have configured the config file, and I have double checked the account, company, region, reset password to only use alphanumeric.
I have used both forms of the URL
The only possibility is that I am using a trial account, but I can't imagine that this would limit external non-browser connections?
I use a simple user/password, I have whitelisted my IP and I don't have a problem with a proxy or a firewall. I can successfully connect using a browser.. using:
https://app.snowflake.com/canada-central.azure/jg63409
Important contents of the config file:
[connections]
accountname=JG3409
#accountname=uegxydq-pz20606
region=canada-central.azure
username=ASHSNOWFLAKE
any ideas?
Your account is not JG3409 but JG63409 based on this link:
https://app.snowflake.com/canada-central.azure/jg63409
Try in your browser:
https://jg63409.canada-central.azure.snowflakecomputing.com
I found out using snowcd that my computer could not connect via my home router.
When I used my personal hotspot on my (5G) phone, snowcd passed all the tests immediately. The problem then arose how to adjust the network security policy to allow a CIDR block of network addresses through since my phone uses a new address every time I connect, and I can't edit the policy to allow my phone while connected via my phone (for obvious reasons)
Catch 22
123.45.0.0/16 is not accepted in the new Snowflake UI, and 0.0.0.0 doesn't work for me, but the documentation gave me a clue.. the new UI doesn't separate by commas, so I switched to the old UI and voila!
Incidentally the OLD UI uses the same URL as SnowSQL so I picked up my error in my account number there as well (although I should have seen it earlier).
Diabolical but thanks #Sergiu too!

Twilo unable to call the status call back url for SMS

We have exposed a url to Twilio to send the sms delivery status and it was working fine when we hosted our service in our own data center.
But we moved our services to aws ; Twilio is unable to call our service and it showing the below error
https://www.twilio.com/docs/api/errors/11200
please help
make sure your Elastic IP Address is reachable using TCP/443 (you enabled this on your EC2 instance, correct) and your application supports both GET and POST methods. Check the Debugger (small bug icon in upper right corner of console) for any relevant error messages, otherwise the error 11200 URL you provided has a lot of extra steps to check.
You should be able to reach your application via your web browser, for testing.
Which IP addresses will Twilio's requests come from?

Cannot reach SIP server

I'm developing a VoIP IOS app using SIP protocol. I have my own SIP parser library and I use GCDAsyncUDPSocket to send data to the server.
The problem is that I can't reach the server on double NAT with my app. I do PING and the server responds immediately PONG, but when I send a SIP package, I can't even reach the server.
I try to reach the server with other clients like Zoiper or Media5 and works perfectly. So I think i'm doing something wrong.
Make sure to:
include your private IP:port in the contact and via headers (not a wrong public address)
add the rport attribute to Via
make sure that the REGISTER message is well formed (is a valid SIP message)
If still doesn't work, check the server logs. If still doesn't work or you don't have access to the server logs, let me see your REGISTER message.

how to send a value via tcp in rails?

I am developing rails app and following are the things that i have done and i need to do.
I am using rails for iphone app and i have an api for sending the values to the server.
When a user sends the value to the server, the value has to be stored in db and i need to show the values to the other user.
The other user should listen to the tcp server and the value should be received by that user.
I have read few examples from https://www6.software.ibm.com/developerworks/education/l-rubysocks/l-rubysocks-a4.pdf and few other examples but i do not know how to proceed.
Please help me.
You can just use plain http (or https) to communicate with iphone app.

I can send an email from my Rails app, but not an SMS text through an email gateway

I have application that needs to send emails and sms text messages. It sends emails just fine, but when I try to send text messages using email gateways (for verizon, xxxyyyzzzz#vtext.com) I get nothing. I have texted the phone using though the email gateway using my gmail account, so I know it works. I would just think that from my app's point of view I am just sending out another email. Any idea why this doesn't work? Or what I can do to troubleshoot it?
I should also note that I am doing this from a Rails app on my local computer...not that it should matter.
Maybe Verizon has software that can identify emails sent from software rather than humans, and rejects yours?
Try making your software add all the same headers (eg. X-Mailer) that a normal email client would add.
Verizon could be doing a reverse DNS query as a simple spam check. Your ISP's info could show up during this look up instead of the return address info that your email message contains, and thus could be getting blocked.
To troubleshot this make sure that the return e-mail address that you are using is coming from an ISP e-mail account.
Here is how to debug it on Linux. Run your Rails application server with strace:
strace -s99999 -e connect,read,write,close -o strace.log script/server
Then examine strace.log and see exactly which SMTP server the Rails application connects to, and what it reads and writes.
Then do the same with your favorite mail client (recommended: mutt, because Thunderbird is slow in strace).
Try to send exactly the same bytes from Rails what your mail client sends.
I have used SMS_Fu in the past to send out text messages. It has worked wonderfully.
I have written a client app for Ruby for sending SMS, please see http://freebiesms.blogspot.com/2009/07/send-free-sms-from-ruby.html to download
complete source code.
Regards
Dan

Resources