Leiningen: unable to use "insecure" proxy repository - clojure

I am running a Nexus repository in my local network that I am trying to get Leiningen (2.8.1) to use. However I'm running into the issue where Leiningen refuses to connect over non-HTTPS connections.
My profiles.clj looks something like this:
{:user
{
:mirrors {#".+" {:name "superbia"
:url "http://localhost:8081/repository/maven-public"}}
}
}
Which gives me this error:
% lein
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.
When looking at that FAQ entry it tells me to add stuff to my project.clj, which I can't, since it refuses to do basically anything, let alone create a project.
Even requesting the version breaks:
% lein -v
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.
Is there any way to disable or bypass this behaviour without either downgrading Leiningen (which is what I did last time) or reconfiguring the proxy repository?

Have a look at: the leiningen FAQ
Q: I got Tried to use insecure HTTP repository without TLS, what is
that about? A: This means your project was configured to download
dependencies from a repository that does not use TLS encryption. This
is very insecure and exposes you to trivially-executed
man-in-the-middle attacks. In the rare event that you don't care about
the security of the machines running your project or can ensure that
the only http traffic is going out over a trusted network, you can
re-enable support for unsafe repositories by putting this in your
project.clj file:
;; never do this (require 'cemerick.pomegranate.aether)
(cemerick.pomegranate.aether/register-wagon-factory! "http"
#(org.apache.maven.wagon.providers.http.HttpWagon.))
It's also possible you have a dependency which includes a reference to an
insecure repository for retrieving its own dependencies. If this
happens it is strongly recommended to add an :exclusion and report a
bug with the dependency which does this.
You can always edit project.clj regardless of lein running or not - just use your favorite editor to edit the file. There is also a per-user $HOME./lein/profiles.clj - you can add the lines above in this file.
Alternatively you can downgrade lein (to ex. 2.7.1), either:
lein upgrade 2.7.1
edit ˜/bin/lein at the top, you should see export LEIN_VERSION="2.7.1"

Related

How to disable auto update of Postman app

Is there a way to disable updates in Postman?
7.26 is buggy for me, it freezes on larger debug data is nresponses, but 7.23 is working perfectly. But even if I set "Automatically download major updates" to disable, it doesn't help, as this is a minor update and gets applied automatically.
Is there a way to really disable updates and stick to the working version of Postman?
Here's my workaround which works on macOS, Linux, Windows, just add these to your hosts file:
0.0.0.0 dl.pstmn.io
0.0.0.0 sync-v3.getpostman.com
0.0.0.0 getpostman.com
0.0.0.0 go.pstmn.io
Here's a tutorial about editing host file for all major operation systems:
https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/
If the above link has any problems, please let me know to update it.
No, the people on Postman simply don't want to let us disable the minor updates.
Here an open issue: https://github.com/postmanlabs/postman-app-support/issues/6999
Let's hope they are sensible to our requests.
There is a way to do it for Windows:
Set Deny on the write permission for everyone on the C:\Users\<username>\AppData\Local\Postman\ directory.
It is not a cross-platform solution, so you can block Postman update servers for Linux and macOS using the host file, which is mentioned in here.

How exactly does the WiX 'Service Install' work internally?

I have a problem with a web service that is installed and started with a .msi that is created with the WiX toolset.
The service can be installed and started on all the machines I tested so far (shown as running in the Services Manager) but on some machines it is not reachable (for example via a browser) and not shown in the list of listening ports on that machine (displayed with 'netstat -a').
I am trying to figure out what's going wrong but I am not really familiar with web service development and configuration. It's a third party service, thus I don't know how it works internally.
A good starting point for me would be to find out, what exactly happens when a service is installed and started during the execution of the .msi-file.
Maybe I could try to tackle the problem on a lower level then.
Below is my code in the ServiceInstall-Element:
<ServiceInstall
Id="ServiceID"
Type="ownProcess"
Vital="yes"
Name="ServiceName"
DisplayName="ServiceDisplayName"
Description="Lorem Ipsum"
Start="auto"
Account="LocalSystem"
ErrorControl="normal"
Interactive="no"
Arguments="action=run">
</ServiceInstall>
The argument is important - without it, the service won't start or run.
Maybe someone else encounterd the same or a similar problem and can help me out.
Thanks already in advance - each hint is appreciated.
EDIT I (15.04.18):
As it might be a problem with the specific service, I will add some further information here:
It's a third party software called CryptoLicensing:
http://www.ssware.com/cryptolicensing/cryptolicensing_net.htm
Part of this software is that specific program, that serves as a License Server and does the license registration, for example in a customer's network.
The service can be run as a Windows application or installed and run as a Windows service. In both cases it should be listening on a (pre-)specified port on the installed machine.
Whenever I start the .exe as an application, everything works as intended. The service is reachable (for example with the browser) and can be accessed from other machines in the network.
When the .exe is installed and started as a service, it does not work as intended on every machine. For example if I install and start the service on my laptop, it is shown as running in the Services Manager, but is not reachable on its assigned URL (not even on the localhost) nor is the specific port displayed in the active listening ports, for example with 'netstat -a'.
The service itself starts without any error messages and does not log any errors or exceptions as it seems to be running without any problems.
I contacted the vendor, but sometimes he doesn't reply quickly and he is not very specific in his replies.
Before asking the question I assumed that it was a problem with the Windows user rights and the WiX installer but during the discussion here I had the feeling that it might a problem with the service itself.
I hope this 'new' piece of information helps in isolating and location the problem.
Thanks to everyone who helped so far!
Hopefully not stating the obvious here, but WiX doesn't do much except populate the ServiceInstall table in the MSI file, so this is about why Windows Installer won't start the service. ServiceInstall table:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa371637(v=vs.85).aspx
Also, this isn't really about ServiceInstall - it's probably about the ServiceControl element in your WiX source, but it's not clear whether that's how you're starting it or if you're starting it manually later on. That does make a difference. What is the error message and where are you getting it, and is it a 1920 or 1921 error (in the context of ServiceControl).
The main reason a service will start on one system but not another is missing dependencies. If your service is C++ based (the post doesn't say) then there are probably dependencies on C runtimes, UCRT runtimes, MFC or ATL runtimes and so on.
First: are you sure this service is intended to run as LocalSystem? (MSDN, SO).
Second: did you check the event logs in detail for anything obvious? If the service is good you should find a hint at least. Something to start with. I find that I sometimes miss the actual logs in the event viewer because it is so "crowded". My take on it: empty the log and stop and restart the service.
Something locking / blocking: If the service installs and runs OK I would suspect other factors such as firewalls (hardware & software), security software in general (anti-virus, malware scanners), network configuration issues (proxies, WINS, DNS and all the complexities involved in networking). Is the service trying to reach an UNC path?
Diverse Machines: What are the target machines? Are they virtual, are they physical, are they test machines, are they operative SOE machines in corporate networks? Are they the same OS version and edition?
Further Ideas: It is not quite related, but maybe skim this list of suggestions for debugging from another answer (I am not sure why it was down-voted, I think it is an OK list to inspire debugging ideas): Windows Application Startup Error Exception code: 0xe0434352 (maybe just skim the bolded words for ideas - Recommended).
sc.exe: And finally, perhaps check the sc.exe tool (Service Control) and see if it can provide you with some useful information for debugging.
sc.exe in the context of killing hung services (sample use).
sc.exe from MSDN
Some further links:
Windows Services Frequently Asked Questions (FAQ). Content seems to be up to date - at face value at least. These guys claim to be experts on services. I have no idea who they are.
Essential Tools for Windows Services: SC.EXE
Run Service Control (sc.exe) command on secure port
After almost 20 months we finally (and accidentally) found a solution to the problem! For the few machines, on which the service did not run properly, setting the NoInteractiveServices value in the registry to 0 did the trick. A value of 1 (which is default) means that no service is allowed to run interactively, regardless of whether it has the SERVICE_INTERACTIVE_PROCESS property. More information on Interactive Services.
I am not completely satisfied with the solution, because on all the other machines NoInteractiveServices is set to 1 AND the service runs properly anyway. However, on the machines where the service did not run interactively this solution worked for us. Thus I will accept this as an answer.
If anyone has more information on this issue and can explain why this works, feel free to
add them - I would be very interested!

How to run lein run and lein figwheel?

For a bit now I've just been running lein figwheel to start up my application. I generated the project using the luminus template. However, recently when connecting to a database I found that lein figwheel does not allow me to connect to database. I'm assuming this is because it does not initialize the app. Which is weird because it will reload my plain clj files with no problem.
However, if I just use lein run then I have the database connection.
After poking around I reread the Luminus docs and it says that I need to run both. And this is where I am very confused. lein run opens a port to 3000, and figwheel opens up a port to 3449. Like I said, the first lets me connect to the database and the other gives me autobuilding. Do I connect to both ports?
So what step am I missing to get both worlds?
Harley mentioned this in the comment to the other answer, but I wanted to vouch for it. First, run your server however you'd like (I launch from the repl, but you can also use lein run). Then use your browser navigate to whatever port you choose to run on. Then run lein figwheel in another terminal and it will connect.
I too, have never done both at the same time. However, I have done them separately and the different ports handle different "services". Port 3000 is the http port. If you built this from a luminus template, then you are probably building a web site. So, connect to 3000 with your browser.
Port 3449 is the web socket port that figwheel uses to push changes to the browswer. So,you start up a command-line lein figwheel an it goes looking for your 3449 port to talk to the browser. Now mind you, this command-line is both a repl and a monitor program. As you make changes to the source, figwheel recompiles your changes and sends the to the page at 3449. You can also execute code from the repl by changing the namespace of the repl (i.e. in-ns).
So, two different ports, two different protocols. What does port 3000 return to the browser? Well, depending on your server, whatever page you tell it to. Whereas, the 3449 is whatever figwheel defaults it to.
The real question is how to get figwheel to connect up to an existing page in a browser, not started by figwheel. I thought I had seen where someone had a JavaScript function that you embedded in your page and it talked/listened to figwheel.

Hawtio stops working after running for days

We are using hawtio to have a fancy and nice web interface for seeing JMX MBeans and Camel Route in our project. However, we have noticed that after weeks running Hawtio stops working and we are getting a Jetty error when trying to access it.
We are using hawtio in standalone mode, version 1.2.0/offline. Also I guess it worth to mention that our Camel routes are pretty heavy and consume many resources (not sure if that impacts hawtio). When trying to access we get this:
HTTP ERROR 404
Problem accessing /ourContextPath/. Reason:
Not Found
Powered by Jetty://
It seems like there is no active resource for our context path and I something went wrong like a thread stopped working or something.
Does anybody have any idea how to solve this or how to find what's causing this? Also, is this a known bug fixed in the latest version (1.2.1)?
Jetty needs a work/temp directory to operate.
Default behavior is to use whatever java.io.tmpdir points to.
However, on many unix installations, this points to /tmp, and that directory is often cleaned out by other processes.
To fix, either specify a java.io.tmpdir to be somewhere other than /tmp
$ java -Djava.io.tmpdir=/var/run/jetty -jar start.jar
or create a ${jetty.base}/work/ directory (if running Jetty 9.1+)
or create a ${jetty.home}/work/ directory (if running versions of Jetty prior to 9.1)
See the answer at Jetty: Starts in C:\Temp for more details on how this work/temp directory operates and is configured.

Add webapp frontend to existing clojure app

I have a Clojure-based chat bot that I start up in typical leiningen fashion with lein run. I'd like to add a front end to this app, but not totally sure how to go about it. From reading docs on compojure, lib-noir and ring, looks like the standard way to serve is with lein ring server. I'd rather just start up the app and the front end with a single lein command if possible. Would this involve manually starting up the server (in another thread perhaps) with something like (run-jetty handler {:port 3000}), or could anyone recommend a better approach?
What do you understand under 'frontend' in your case? I see two possibilities.
First one is when your Clojure bot is completely standalone and has some external interface to interact with. In this case your frontend will be separate application talking with the bot via this external interface, and indeed in this case if you want to start your programs with single lein command you should be using explicit -main function in your webapp which will first run your bot and then start the server. I don't know exact command to start the server though; yours looks fine for me, but I think I read somewhere that this kind of startup was deprecated...
Another possibility is when you want the webapp to be integrated into the bot. In this case you just write the webapp in such way that it uses namespaces of the bot directly; no -main function is required, and all you have to do is run the lein ring server command.
The second one looks clearer to me, but it depends on overall architecture of your bot.
Update.
I have looked more thoroughly at how ring and leiningen work together, and it seems that the simplest way for you to get what you want is as follows. First, install lein-ring plugin as its readme directs.
Next, configure your project.clj similarly to the following:
(defproject your-project "0.0.1"
:dependencies [...]
... ; All other configuration
:ring {:handler your-namespace.web/handler
:init your-namespace.bot/init})
See, you should have additional options in your project.clj file (they are described in the readme I have linked to above). :handler is your main web application handler (refer to ring documentation on what it is and why it is needed). :init should be your initialization function. This is exactly the place you should add the code to to start your bot.
Finally, issue lein ring server command to start your webapp. This will first call a function you specified as :init in your project.clj, which in turn will start your bot, and then your webapp will be launched.