Socky connection failure - ruby-on-rails

I get this kind of log when ever i start socky server
>> Thin web server (v1.2.11 codename Bat-Shit Crazy)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3001, CTRL+C to stop
Socky : sending : {"event":"socky:connection:established","connection_id":"1320836395810196"}
Socky : received : {"event":"socky:subscribe","channel":"bizcard-updated-2011nov09-115943","connection_id":"1320836395810196"}
Socky : sending : {"event":"socky:subscribe:failure","channel":"bizcard-updated-2011nov09-115943"}
I am using
gem 'socky-client', '0.5.0.beta1'
Actually I cant figure it out why socky:subscribe:failure ie socky is not able to subscribe.
I once ran it and the subscription is also successfully. But some how later on this kind of message is being displayed.
However Socky get the data put not able to send it
Socky : received : {"event"=>"event_name", "channel"=>"channel name", "timestamp"=>"1320837649", "data"=>"\"content_hash\"", "auth"=>"auth_string"}
I am not able to figure it out why socky is not able to send data to browser.

Looks like the channel name is to long :(
I just had the same error trying to make a channel name with 33 characters.. but when i shortened it to 24 it worked fine.
I hope that helps.

Related

`Unsafe redirect to "https://${ip}/signin"` while running rails application

I'm trying to analyze log from my rails applications I sometimes see hits from random IP addresses that look like this:
-------------------------------
Request:
-------------------------------
* URL : https://${ip}/
* HTTP Method: GET
* IP address : 162.62.191.231
* Parameters : {"controller"=>"runner", "action"=>"index"}
* Timestamp : 2022-08-17 18:28:07 +0300
* Server : b82b789929df
* Rails root : /root/my_app
* Process: 270
Those are not some replacement to hide IP from you, it seems like literally request with https://${ip}/ value
But not sure from where it's coming, probably some guys are testing my site for some vulnerability, but I cannot detect which.
https://${ip}/ is a really bad string to google it
And especially I cannot understand how to simulate the same request with curl or wget to see if it really safe
Fact is that it couldn't get to your server unless it was a correct hostname/ip-address, so that URL is not what's being requested. My guess here is that this is some local monitoring or health-check, is this on AWS?

Quectel M95 HTTP POST timeout error

I'm trying to send a POST to a server but I always get the +CME ERROR: 3821. I know that this means "HTTP to read timeout". Then, I tried to change the server to another one, just to test, and then I get the same error 3821. My AT commands list is:
AT+CGATT=1
AT+QIFGCNT=0
AT+QICSGP=1,"zap.vivo.com.br"
AT+QIACT
AT+QILOCIP (IP OK!)
AT+QHTTPURL=38,30
CONNECT
http://www.posttestserver.com/post.php
OK
AT+QHTTPPOST=10,50,80
CONNECT
helloworld
OK
+CME ERROR: 3821
Does anyone know what is wrong?
I solved it by using directly
AT+QHTTPPOST=10,50
and not
AT+QHTTPPOST=10,50,10
hello even the issue is one year old i am writing answer if any one needs. In the source file of "ril_http.c" of Quectel modules, add delay of minimum 10ms in HTTP call back handler. it will solve the timeout error and will able to post it successfully.

Mirth Connect HTTP Listener Mapping Response ACK message

We are trying to merge two Mirth servers. One server (let's call it Server 1) is keeping all records and another server (Server 2) is getting HL7 message from the first one and writes messages to the database.
Everything was perfect so far. But Server 1, after sending each HL7 message, waits for ACK to consider this transaction as completed and to send another message from the list.
The success status coming from the Server 2 (which writes to the database) contains MySQL response such as "Success: Database write success. 1 rows updated.". This is not what Server 1 is expecting.
Therefore, the Server 1 considers this ACK as invalid, produces an error "Message Read Error - Will Retry" and keeps trying to send the same message again, causing Server 2 to duplicate messages in the database.
We are using Mirth Connect HTTP listener and we could not find any solution to send ACK msg to our first server the same screen HTTP listener.
Is there any way to do this? Any Suggestion?
Really need help.
The problem is you are not setting the response from server 2 correctly, so it just returns what the destination has. You can create an ACK by code on the destination transformer:
var ackMessage = ACKGenerator.generateAckResponse(connectorMessage.getRawData(), "AA", "Message Successfully Received");
responseMap.put("ackresp", ResponseFactory.getSentResponse(ackMessage));
And on your source connector select "ackresp" as response. Your server 1 will receive that ACK instead of the log of the database write.

receive TCP/IP data on a rails application

I have a custom device with a TCP/IP stack implemented that's sending a byte each 5 seconds to a remote IP.
On that remote IP, I'm building a site with rails 3.1.3 that will have to receive, store and display the data sent by the custom device.
I was thinking on having a TCP Socket running in the background, something like this, but i don't have a clue on how to integrate this with a rails site. Where to place it, how to start it and how to propagate the data to the views.
Does anybody have a clue on how shall I proceed?
To solve this I created a raketask that starts a TCP Server that will handle messages.
Note: This code has more than a year so I'm not 100% sure how it behaves, but I think the core part is this:
#server = TCPServer.new(#host, port)
loop do
Thread.start(#server.accept) do |tcpSocket|
port, ip = Socket.unpack_sockaddr_in(tcpSocket.getpeername)
begin
loop do
line = tcpSocket.recv(100).strip # Read lines from the socket
handle_message line # method to handle messages from the socket
end
rescue SystemCallError
#close the sockets logic
end
end
end

How to check server connection

i want to check my server connection to know if its available or not to inform the user..
so how to send a pkg or msg to the server (it's not SQL server; it's a server contains some serviecs) ...
thnx in adcvance ..
With all the possibilities for firewalls blocking ICMP packets or specific ports, the only way to guarantee that a service is running is to do something that uses that service.
For instance, if it were a JDBC server, you could execute a non-destructive SQL query, such as select * from sysibm.sysdummy1 for DB2. If it's a HTTP server, you could create a GET packet for index.htm.
If you actually have control over the service, it's a simple matter to create a special sub-service to handle these requests (such as you send through a CHECK packet and get back an OKAY response).
That way, you avoid all the possible firewall issues and the test is a true end-to-end one. PINGs and traceroutes will be able to tell if you can get to the machine (firewalls permitting) but they won't tell you if your service is functioning.
Take this from someone who's had to battle the network gods in a corporate environment where machines are locked up as tight as the proverbial fishes ...
If you can open a port but don't want to use ping (i dont know why but hey) you could use something like this:
import socket
host = ''
port = 55555
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
s.listen(1)
while 1:
try:
clientsock, clientaddr = s.accept()
clientsock.sendall('alive')
clientsock.close()
except:
pass
which is nothing more then a simple python socket server listening on 55555 and returning alive

Resources