textbelt
textbelt copied to clipboard
Textbelt Standalone Windows Error
I have installed TextBelt on IIS (using iisnode) Windows Server 2012 platform. I have followed the instructions on https://github.com/typpo/textbelt for standalone. When I try to run the service using:
node server\app.js
I get the following response:
C:\Program Files\iisnode\www\textbelt>node server\app.js
{ Error: ENOENT: no such file or directory, open 'C:\Program Files\iisnode\www\textbelt\server\torlist' ``at Error (native)
at Object.fs.openSync (fs.js:634:18)
at Object.fs.readFileSync (fs.js:502:33)
at Object.<anonymous> (C:\Program Files\iisnode\www\textbelt\server\app.js:42:24)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Function.Module.runMain (module.js:575:10)
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Program Files\\iisnode\\www\\textbelt\\server\\torlist' }
Listening on 9090
Since it says it is "Listening" I try to access the service to send a message and Visual Studio debug says:
The underlying connection was closed: An unexpected error occurred on a receive.
And then I get the following information in the log:
txting phone 5556567898 : Hello, World! ``Hello, World!
events.js:160
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at exports._errnoException (util.js:949:11)
at Socket._writeGeneric (net.js:705:26)
at Socket._write (net.js:724:8)
at doWrite (_stream_writable.js:307:12)
at writeOrBuffer (_stream_writable.js:293:5)
[at Socket.Writable.write (_stream_writable.js:220:11)](url)
at Socket.write (net.js:650:40)
at Object.sendText [as send] (C:\Program Files\iisnode\www\textbelt\lib\text.js:83:15)
at doSendText (C:\Program Files\iisnode\www\textbelt\server\app.js:166:10)
at Command.callback (C:\Program Files\iisnode\www\textbelt\server\app.js:240:7)
I am not sure if this is due to the first failure when running the service or if this is an IIS issue (some simple permissions thing I am not doing). I have opened the port in Windows Firewall for both the service and Redis. Any help would be greatly appreciated. Thank you!
Two things:
- it seems you are trying to run the standalone server within IIS. That's actually not necessarily and overkill. If you have node.js installed, you can just run it the same (across Linux, Mac, Windows). Start it from the command line and you should be able to hit it over the REST API over HTTP on port 9090. I have no idea how you are supposed to "properly" run it with iisnode, likely not how you are doing it. I'm assuming iisnode deployment should work more the IIS way, configuring and starting it up the IIS way (not from the command line). I recommend you try running it outside of IIS first. Why do you want to run it over IIS/iisnode? If you really need to run in IIS/iisnode, I suggest you make sure you are deploying it correctly, I have a hunch you aren't. Maybe even contact that project's author (of issnode) for help.
- based on the error, and looking at the server code,
server\app.js at line 42, it appears the server expects a banned IP list file namedtorlistin the same folder to work, although it is supposed to catch the error if it fails and just logs the error to the command line output and continue on. Seems in your particular deployment scenario it might not be continuing/resuming properly. You could try as a workaround creating an empty (text) file named torlist (no file extension to it) and put it in the same folder. Maybe even stick in a dummy IP address in there if need be.
This might be a good starting point for iisnode deployment (of textbelt): https://tomasz.janczuk.org/2011/08/hosting-express-nodejs-applications-in.html
It would seem you don't have to start anything on the command line, e.g. node server\app.js
once configured correctly for iisnode per that tutorial, you just access with a REST client (browser based REST client or using code) to make an HTTP POST to
http://yourhost:9090/text
with Content-Type header set to application/x-www-form-urlencoded
and sending the phone number and text messages as form POST key/value pairs in the request body.
The port may not be 9090 if you've configured it differently in IIS/iisnode/Windows, so it might be 80 (in which case you can leave out the port number) or 8080 for example. You could explicitly set it for 9090, best not to leave it undefined and let textbelt try to default to 9090.
Also per that tutorial, you have to set up URL rewrite rule for textbelt so that IIS forwards the REST URLs to textbelt to handle. And relating to that, you might have to modify the REST API paths in server\app.js depending on how you've hosted it in IIS, e.g. edit lines 75, 81, 86, 99, 103, the app.get/post entries)
Let us know how things go. Would be good to have a writeup for others on how to get textbelt working under IIS with iisnode.
Hi warren8r,
The torlist error is safe to ignore. It's meant to be informative, and I should make that clearer in the code. The presence of a torlist file is optional.
I think the EPIPE error happens when the pipe from Textbelt to the mailer is interrupted. It seems related to this issue: https://github.com/nodejs/node-v0.x-archive/issues/3211
Try including one of the suggested solutions at the top of your app: https://github.com/mhart/epipebomb and see if that changes anything?
Hello typpo, Thank you so much for your reply. I am hoping by the end of this, I can provide a writeup. Anyway, I am going to add an empty torlist to resolve the previous issue, but the second issue is still of some concern. I must disclose that my knowledge of SMS technology and flow is very infantile. Do I need to provide some separate email server to self-host this or is it self-contained? I will try epipebomb to see if this stifles the interruption. If Textbelt is expecting to interract with a separate email server provided by me, then I am missing a huge hole. Am I making any sense? Thanks for your patience and help. Sincerely, Matt
Update: I have added an empty torlist file to the server folder and that has resolved the expected 'banned ips' parameter. No more ENOENT error. One last error that is critical: I am able to connect to the service, but as I send a text it still bombs with the EPIPE error. It's like something is breaking as it's unable to send the text. I have installed EPIPEBOMB, but while this seems to keep the avenue open, it's as if something isn't there to interface with the carriers? Maybe I am way off. Thank you in advance for your help.
The issue here is most likely that Textbelt depends on mutt. I should make this dependency clearer in the README. It's possible to modify it to use sendmail or something like that instead, but you'd have to get down in the code.
Mutt is an email client. According to the mutt website, there is a windows version: http://www.mutt.org/download.html
Thank you so much, typpo! So can you tell me how mutt works (as a component of Textbelt)? Does mutt communicate with a Textbelt email server? In general, how does an SMS get sent? Thanks for your time. I apologize for the low level of experience as these events are still unclear to me.
Hey warren8r, sorry for the delay.
The SMS get sent by a mail client directly to the email gateway of all providers.
For example, you can text a Verizon number by emailing [email protected]. When you send a text to 9876543210 via Textbelt, it tells mutt to send an email to vtext.com with your message.
So as you can see, unfortunately, the mail client is a critical dependency!
@typpo No worries! Thank you for the reply. I am ALMOST there! I gave up on Sendmail for now, as I was getting a message sent success but not receiving the message on the other end. I have mutt configured for gmail, just to get something working, then I will try to get Sendmail working and re-configure mutt for Sendmail. BTW - do you use Sendmail in the original Textbelt? Thanks again for your time and attention. Sincerely, Matt
Curious @typpo, why do we use mutt if textbelt is node.js based? I believe any node.js email client (library) can send the email instead of relying on mutt. I myself use the emailjs module to send out emails.
Using a node.js email client/library allows you to self contain the dependency with node/npm rather than having to externally have mutt preconfigured/installed on one's textbelt server. Or is it a matter of scale with mutt being performant in sending many emails?
@warren8r Textbelt originally used sendmail. You and @daluu are absolutely right that this would make more sense.
I was running into weird issues where providers blocked Textbelt email, which brought the service down from time to time. You can still see there are a couple issues open that are related to this. I noticed that mutt solved this problem. I looked into the headers and tried to match them 1-to-1 in sendmail/mail, but still had trouble for some reason. So, I decided to just switch to mutt because the vast majority of usage (as far as I know) is through textbelt.com rather than self-hosting, so it made sense to fix textbelt.com ASAP.
It would certainly be possible to revert to the old mail code, which was changed in 19b7403174410cb5f0b04b11f8e2eb00d6ebc633. sendmail code is similar.
There's probably some email client library for node that will work. emailjs has an smtp server dependency though. Textbelt send mail itself rather than going through an smtp server. This is because the amount of emails/texts Textbelt sends per day would be considered abusive by any public smtp server.
@typpo and @daluu, Hey guys, I got it working using mutt->gmail (for now). My main problem is phone numbers that have reached quota - how to I refresh the quota for a particular phone number? Where are these things stored?
Nice!
Rate limiting info is stored in redis. You can go into your redis db using redis-cli and run the command flushdb to empty everything out.
Thank you so much, @typpo Couldn't have done it without your help and @daluu BTW - let me know if you guys want to work together to get sendmail firing on all cylinders