`cider-jack-in' aborts with 'Protocol family unavailable' - emacs

When I run cider-jack-in I get a SocketException with Protocol family unavailable as the exception message.
lein repl runs fine on the command line.
I've web-searched and found no matches containing both 'cider' and 'SocketException', which is always worrying. Nothing obvious came up in a search of the github project nor in the list of possibly-related questions presented here by StackOverflow as I'm writing this.
I get the same error whether I have a project file loaded or not.
My Emacs session tends to be extremely long-running (months) but I've checked and the problem still recurs identically after a restart.
Things I thought of that might be at play but I think I can discount:
AFAIK no hosts on the subnet (this host among them) have IPv6 configured on any interface.
This Emacs is running on the same host as a Squid proxy server, but (getenv "no_proxy") returns a comma-delimited string that includes both localhost and 127.0.0.0/16, so no connection to the proxy server should be requested as part of connecting to an nrepl server on the same host.
This host has a heavily customized /etc/hosts file, but no IPv6 address mappings are enabled.
In other words it should be a "pure" IPv4 host.
emacs-version: 24.5.1
cider-version: 0.15.1-snapshot
OS: Linux this-host 4.8.0-2-amd64 #1 SMP Debian 4.8.11-1 (2016-12-02) x86_64 GNU/Linux
Stack trace header:
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: Exception in thread "main" java.net.SocketException: Protocol family unavailable, compiling:(/tmp/form-init7765774181037314573.clj:1:73)
What's wrong?

I doubt that cider knows or cares whether your system is purely ipv4; it still
seems to default to attempting use ipv6, shown in cider's startup messaging as
lein ... repl ... :host :: (the :: being ipv6 equivalent notation
to localhost). For my
situation, it was simple enough to just enable ipv6 on my system, but you
could instead follow suggestions in this
issue to set
cider-lein-parameters to repl :headless :host localhost.

Related

Developer exception starting a client-server model on Eiffel net

I'm trying to establish a connection using sockets between 2 PC's on the same LAN using the Eiffel Programming Language. I'm trying to run the examples that are by default on the installation directory of Eiffel Studio. However right now I'm trying to make it on the same machine by addressing to localhost (127.0.0.1).
It works perfectly on Linux (Ubuntu 15.10) but on windows 7 I'm getting an exception when I try to run the client program. The code of the exception is 24 Unable to establish connection. The server program runs just fine and I already got a connection between a client on linux and a server on windows. I didn't find a solution to this exception on the documentation nor on other sites. Here is a screencap:
Screencap of the debugger
Here is a link to the doc:
https://www.eiffel.org/doc/solutions/Two%20Machines
Thank you in advance.
The issue might be caused by the fact that some ports are used and others are reserved by the system. In particular the port range 0-1023 is designated for use by common system and network services. Ports beyond this range can also be registered (e.g., Service Name and Transport Protocol Port Number Registry or List of TCP and UDP port numbers). System security settings could also prevent applications from using specific port numbers.
The solution is to look for and to use port numbers that are available for user applications. Ports currently used on Windows can be found with netstat -an, what can be used is related to TCP/IP and firewall settings. The simplest approach is to try using some other port numbers, e.g. in the range 1024-49151.

Socket Exception in Visual Studio load test

While executing a load test within Visual Studio I keep hitting the following error:
SocketException Only one usage of each socket address
(protocol/network address/port) is normally permitted x.x.x.x:443
once I ramp up to a certain number of users. Now I have adjusted the registry settings regarding the MaxUserPort (to 65534) and the TcpTimedWaitDelay (to 30) and this has made no difference.
This is Visual Studio 2012 on Windows Server 2012.
Does anyone have any suggestions?
At a guess, since you haven't provided enough information, you are binding and connecting outbound sockets, and you are trying to re-use local port numbers. You can't do that. Get rid of the bind step and let the system allocate the local port number. However you will then discover that you still run out of ports with a bind error, or possibly this is the bind error, and this is because using a single client program as a server load test is fundamentally invalid. Your only recourse is to use fewer connections and more client hosts as well.

RhodeCode - What is blocking my connection?

All connection attempts on RhodeCode on CentOS 6.3 are refused except from localhost.
Note that iptables is not running, and I am only trying to visit the web interface.
I have googled the exact error message below and looked around SO. I have yet to find a solution.
abort: error: No connection could be made because the target machine actively refused it
If the firewall is down, and I am not trying to modify any repository, what else is preventing me from connecting? EDIT: See #5 below. Not sure how to address it yet.
Things tried and other info
Using localhost, 127.0.0.1 and hostname in production.ini
service iptables stop
Connected over HTTP successfully. In other words, connections are accepted outside RhodeCode.
Made sure no authentication methods were enabled or configured in production.ini
Although the server accepts connections on localhost, netstat -l does not show that port 5000 is listening. Port 5000 is set in production.ini and ps uax | grep paster confirms the server is running. No other software tries to grab port 5000.
Ok, apparently I have been misunderstanding the host configuration. I was running on the assumption that host should be set to 127.0.0.1 or localhost in production.ini for RhodeCode to know what host to look for for another service. This was a faulty presumption on my part, since I am used to pointing web applications to local systems to look for databases.
It turns out that host binds the application to a specific address for access, meaning that it RhodeCode was supposed to only respond to local requests, regardless of what other system policies say. The setup docs did not make this clear because it did not specify that external connections would be refused. All it said was:
This command [paster serve] runs the RhodeCode server. The web app should be available at the 127.0.0.1:5000. This ip and port is configurable via the production.ini file created in previous step
The problem was fixed by binding RhodeCode to 0.0.0.0, which opened it to outside connections. Kudos to Ɓukasz Balcerzak for pointing this out in the RC support google group.

Accepting a socket on Windows 7 takes more than a second

Here's what I've done:
I wrote a minimal web server (using Qt, but I don't think it's relevant here).
I'm running it on a legal Windows 7 32-bit.
The problem:
If I make a request with Firefox, IE, Chrome or Safari it takes takes about one second before my server sees that there is a new connection to be accepted.
Clues:
Using other clients (wget, own test client that just opens a socket) than Firefox, IE, Chrome, Safari seeing the new connection is matter of milliseconds.
I installed Apache and tried the clients mentioned above. Serving the request takes ~50ms as expected.
The problem isn't reproducible when running Windows XP (or compiling and running the same code under Linux)
The problem seems to present itself only when connecting to localhost. A friend connected over the Internet and serving the connection was a matter of milliseconds.
Running the server in different ports has no effect on the 1 second latency
Here's what I've tried without luck:
Stopped the Windows Defender service
Stopped the Windows Firewall service
Any ideas? Is this some clever 'security feature' in Windows 7? Why isn't Apache affected? Why are only the browsers affected?
If you're saying "localhost" instead of "127.0.0.1", you're forcing a name lookup before the actual connection attempt, adding delay.
In addition, some browsers, like Firefox 3.5+, don't use the operating system's DNS lookup mechanism, which is why it can have different performance than, say, wget.
You may be running into some automatic proxy discovery problem. In Firefox, you can disable this in Options | Advanced | Network | Settings; select either "No proxy" or give it explicit values. There's also the Internet Properties control panel, which is IE's network settings, but other browsers on Windows may obey settings here, too. Again, disable auto-proxy discovery. This can speed connections outside localhost, too.
For some reason Windows 7 takes 1 second to resolve address localhost regardless of it being in hosts file.
Adding localhost1 to hosts file and using that works around the problem.
When connecting to localhost on a IPv4/IPv6 dual stack host:
A DNS lookup is performed for localhost.
The DNS server (whether IPv6 enabled or not - this doesn't matter) returns both the AAAA record ::1, and the A record 127.0.0.1.
The client first attempts to connect to ::1.
We assume your server program is not IPv6-capable, which is a common case - due to historical reasons, many servers bind their socket to 0.0.0.0 by default rather than [::].
Here an ECONNREFUSED error would be raised for the client. This happens immediately on most platforms; on Windows however, a single call to connect() would try 3 times in 500ms intervals before giving up, hence taking a bit more than one second (See http://stackoverflow.com/q/19440364 for more details).
The client then creates a connection to 127.0.0.1 instead.
This would explain all your clues above:
If you make a request with Firefox, IE, Chrome, Safari or any other IPv6-capable clients, it takes takes about one second trying for ::1 before connecting to 127.0.0.1.
Your own test client just opens a INET socket, so it won't try ::1 at all.
Using a dual-stack server such as Apache, the clients will connect to ::1 happily.
The problem isn't reproducible on Windows XP, of which IPv6 support is not enabled by default.
The problem seems to present itself only when connecting to localhost, as your friend connected with an IPv4-only network.
Running the server in different ports has no effect on the 1 second latency.

How can I set the port that the Emacs Server uses?

I use Emacs to do most of my development work, I'd like to be able to connect to the Emacs server running on my office workstation from home. I connect to my office network over a VPN, I think this is mostly safe.
Anyway, I have a script that copies the server authentication file out, but it looks like the port changes every time. Our VPN is pretty locked down, I need to tell our sysadmin what ports I want open to which machines.
Is there a way to set the port that the Emacs server listens on?
Looks like this is now fixed. I'm using Emacs 24.3.1 and there is now a variable server-port:
C-h v server-port RET
gives the following documentation:
Documentation:
The port number that the server process should listen on.
This variable only takes effect when the Emacs server is using
TCP instead of local sockets. A nil value means to use a random
port number.
You can customize this variable.
This variable was introduced, or its default value was changed, in
version 24.1 of Emacs.
so a (setq server-port 12345) in your init file should do the trick.
Someone posted a small patch to allow customizing the server port to the Emacs Bugs list in September 2008. However, the patch didn't make it into Emacs 23.1 nor does it appear in CVS Emacs as of yet. Your best bet for now might be to patch your version of server.el locally.