I have been attempting to send text to my network printer using a tcp connection.
function print(buf2){
var printer = new net.Socket();
printer.connect(printer_port, printer_name, function() {
console.log('Connected');
printer.write(buf2);
printer.end()
});
}
Initially, everything works perfectly. However, after some time, I encounter an error Uncaught Error: connect ETIMEDOUT which prevents the connection with my printer.
To temporarily resolve this issue, I navigate to my printer's IP address (192.168.1.111) in a browser, and the application reconnects successfully. Nevertheless, the problem reoccurs after some time resulting in the same error (Uncaught Error: connect ETIMEDOUT).
My application is built with electron and utilizes the net npm package.
var net = require('net');
Within my application, every 3 seconds I trigger a get request followed by calling the print method.
function proxy() {
var client = new HttpClient();
client.get('my_link', function(response) {
var jsonItem = JSON.parse(response)
if(jsonItem.items.length > 0)
{
var text_to_print = jsonItem.items[0].text
print(text_to_print,text_id);
}
Any insights into what might be causing this error?