scanservjs

SANE scanner nodejs web ui

Getting started

Installation and setup

  1. Standard install
  2. Docker install
  3. SANE setup install
  4. Troubleshooting

Configuration

  1. Configuration
  2. Integration
  3. Recipes
  4. Using a proxy

Developing

  1. Development
  2. Localisation
  3. Testing
  4. References
  5. QNAP

View the Project on GitHub sbs20/scanservjs

Troubleshooting

Overview

Scanservjs works by wrapping CLI calls to scanimage as the user scanservjs which is a member of the scanner group. The chances are that if scanservjs does not work, then neither does scanimage.

scanimage can either connect to:

Getting logs

Use journalctl. See the journalctl manpage for details but the following should be enough to get you started.

sudo journalctl -e -u scanservjs

Verify connectivity

Verify connectivity for scanservjs

Try running as the application user:

sudo su --shell /bin/bash - scanservjs --command 'scanimage -L'

If this does not work, see below. If it does then take it a step further and run a scan:

sudo su --shell /bin/bash - scanservjs --command 'scanimage --format tiff > test.tif'

which should output a tif file in the scanservjs home directory (/var/lib/scanservjs/). If you can get this to work then scanservjs should be working fine.

Permissions; scanimage works with sudo but not without

Most likely you need a udev rule, but also verify group membership.

scanimage: sane_read: Invalid argument

This is a problem with SANE rather than scanservjs. It usually signifies a problem with the driver. Your best bet is going back to first principles with SANE itself. Follow the steps here

Cropping results in incorrect positioning

Some scanners mis-report their size - don’t know why, but they do. This means that when the app attempts to crop things the maths is all wrong. The best way around this is to override the reported scanner dimensions. See this recipe for more.

JSON.parse error

This happens when the browser received a string from the server which is not a valid JSON string. Most likely you’re running a proxy server (e.g. nginx) which is timing out prior to the completion of the request. Scanservjs can sometimes take a little while to fulfil its requests - usually because it’s waiting for a scanner, but sometimes because it’s having to do a fair amount of image processing and you’re running on a low power CPU (e.g. RPi).

The solution is to increase the proxy timeout. For nginx that might look like:

server{
   ...
   proxy_read_timeout 300;
   proxy_connect_timeout 300;
   proxy_send_timeout 300; 
   ...
}

Long scan timeout

When scanning files with high resolution, e.g. 1200dpi it is very likely for the request to timeout. This is because node HTTP times out after 2 minutes by default. The solution is to increase the default timeout. That’s possible by setting config.timeout = 600000; (for 10 minutes for example).

Docker container loses scanner after device reboot

As per issue #505 containers can lose their access to a device after a device reboot.

This is more SANE and containers than this app. The user’s solution was to add a udev rule as below. You will need to substitute your own product and vendor variables.

/etc/udev/rules.d/99-printer.rules

SUBSYSTEMS=="usb",KERNELS=="1-1.1",DRIVERS=="usb",ATTRS{idProduct}=="0827", ATTRS{idVendor}=="04b8", ATTRS{serial}=="L53010612130846360",SYMLINK+="%s{manufacturer}_printer",TAG+="systemd",RUN+="/bin/bash -c '/usr/bin/systemctl restart container-scanservjs.service &'"

Poor quality (weird or blocky) scans on Raspberry Pi

USB-only scanners draw a lot of current relative to the Pi’s available power. This can manifest itself in unusual scans - technically valid images but with odd colours and block transforms. Consider using a powered USB hub (e.g. for a Canon LIDE 20). If you encounter similar then see here.