You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Darniz <rn...@edmunds.com> on 2011/01/27 07:45:57 UTC

configure httpclient to access solr with user credential on third party host

Hello,
i uploaded solr.war file on my hosting provider and added security
constraint in web.xml file on my solr war so that only specific user with a
certain role can issue get and post request. When i open browser and type
www.maydomainname.com/solr i get a dialog box to enter userid and password.
No issues until now.

Now the issue is that i have one more app  on the same tomcat container
which will index document into solr. In order for this app to issue post
request it has to configure the http client credentials. I checked with my
hosting service and they told me at tomcat is running on port 8834 since
apache is sitting in the front, the below is the code snipped i use to set
http credentials.

CommonsHttpSolrServer server = new
CommonsHttpSolrServer("http://localhost:8834/solr");
      Credentials defaultcreds = new
UsernamePasswordCredentials("solr","solr");
  server.getHttpClient().getState().setCredentials(new
AuthScope("localhost",8834,AuthScope.ANY_REALM),
                        defaultcreds);

i am getting the following error, any help will be appreciated.
ERROR TP-Processor9 org.apache.jk.common.MsgAjp - BAD packet signature 20559
ERROR TP-Processor9 org.apache.jk.common.ChannelSocket - Error, processing
connection
java.lang.IndexOutOfBoundsException
        at java.io.BufferedInputStream.read(BufferedInputStream.java:310)
        at org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:621)
        at
org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:578)
        at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:686)
        at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
        at java.lang.Thread.run(Thread.java:619)
ERROR TP-Processor9 org.apache.jk.common.MsgAjp - BAD packet signature 20559
ERROR TP-Processor9 org.apache.jk.common.ChannelSocket - Error, processing
connection
java.lang.IndexOutOfBoundsException
        at java.io.BufferedInputStream.read(BufferedInputStream.java:310)
        at org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:621)
        at
org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:578)
        at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:686)
        at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
        at java.lang.Thread.run(Thread.java:619)


-- 
View this message in context: http://lucene.472066.n3.nabble.com/configure-httpclient-to-access-solr-with-user-credential-on-third-party-host-tp2360364p2360364.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: configure httpclient to access solr with user credential on third party host

Posted by Thibaut <la...@gmail.com>.
hi

I just wrote a plugin for Lutece portal to restrict access to read/write 
of solr to Lutece admin and read access for the rest: http://goo.gl/f3pGA

t.


Re: configure httpclient to access solr with user credential on third party host

Posted by Upayavira <uv...@odoko.co.uk>.

On Thu, 27 Jan 2011 13:47 -0800, "Darniz" <rn...@edmunds.com>
wrote:
> 
> thanks exaclty i asked my domain hosting provider and he provided me with
> some other port
> 
> i am wondering can i specify credentials without the port
> 
> i mean when i open the browser and i type 
> www.mydomainmame/solr i get the tomcat auth login screen.
> 
> in the same way can i configure the http client so that i dont have to
> specify the port 

Sure. This likely means your traffic is going via Apache (on the default
port 80) but there's no real problem with that.

Upayavira
--- 
Enterprise Search Consultant at Sourcesense UK, 
Making Sense of Open Source


Re: configure httpclient to access solr with user credential on third party host

Posted by Jayendra Patil <ja...@gmail.com>.
This should help ....

HttpClient client = new HttpClient();
client.getParams().setAuthenticationPreemptive(true);
AuthScope scope = new AuthScope(AuthScope.ANY_HOST,AuthScope.ANY_PORT);
client.getState().setCredentials(scope, new
UsernamePasswordCredentials(user, password));

Regards,
Jayendra

On Thu, Jan 27, 2011 at 4:47 PM, Darniz <rn...@edmunds.com> wrote:
>
> thanks exaclty i asked my domain hosting provider and he provided me with
> some other port
>
> i am wondering can i specify credentials without the port
>
> i mean when i open the browser and i type
> www.mydomainmame/solr i get the tomcat auth login screen.
>
> in the same way can i configure the http client so that i dont have to
> specify the port
>
> Thanks
> darniz
> --
> View this message in context: http://lucene.472066.n3.nabble.com/configure-httpclient-to-access-solr-with-user-credential-on-third-party-host-tp2360364p2364190.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: configure httpclient to access solr with user credential on third party host

Posted by Darniz <rn...@edmunds.com>.
thanks exaclty i asked my domain hosting provider and he provided me with
some other port

i am wondering can i specify credentials without the port

i mean when i open the browser and i type 
www.mydomainmame/solr i get the tomcat auth login screen.

in the same way can i configure the http client so that i dont have to
specify the port 

Thanks
darniz
-- 
View this message in context: http://lucene.472066.n3.nabble.com/configure-httpclient-to-access-solr-with-user-credential-on-third-party-host-tp2360364p2364190.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: configure httpclient to access solr with user credential on third party host

Posted by Upayavira <uv...@odoko.co.uk>.
Looks like you are connecting to Tomcat's AJP port, not the HTTP one.
Connect to the Tomcat HTTP port and I suspect you'll have greater
success.

Upayavira

On Wed, 26 Jan 2011 22:45 -0800, "Darniz" <rn...@edmunds.com>
wrote:
> 
> Hello,
> i uploaded solr.war file on my hosting provider and added security
> constraint in web.xml file on my solr war so that only specific user with
> a
> certain role can issue get and post request. When i open browser and type
> www.maydomainname.com/solr i get a dialog box to enter userid and
> password.
> No issues until now.
> 
> Now the issue is that i have one more app  on the same tomcat container
> which will index document into solr. In order for this app to issue post
> request it has to configure the http client credentials. I checked with
> my
> hosting service and they told me at tomcat is running on port 8834 since
> apache is sitting in the front, the below is the code snipped i use to
> set
> http credentials.
> 
> CommonsHttpSolrServer server = new
> CommonsHttpSolrServer("http://localhost:8834/solr");
>       Credentials defaultcreds = new
> UsernamePasswordCredentials("solr","solr");
>   server.getHttpClient().getState().setCredentials(new
> AuthScope("localhost",8834,AuthScope.ANY_REALM),
>                         defaultcreds);
> 
> i am getting the following error, any help will be appreciated.
> ERROR TP-Processor9 org.apache.jk.common.MsgAjp - BAD packet signature
> 20559
> ERROR TP-Processor9 org.apache.jk.common.ChannelSocket - Error,
> processing
> connection
> java.lang.IndexOutOfBoundsException
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:310)
>         at
>         org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:621)
>         at
> org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:578)
>         at
> org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:686)
>         at
> org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
>         at java.lang.Thread.run(Thread.java:619)
> ERROR TP-Processor9 org.apache.jk.common.MsgAjp - BAD packet signature
> 20559
> ERROR TP-Processor9 org.apache.jk.common.ChannelSocket - Error,
> processing
> connection
> java.lang.IndexOutOfBoundsException
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:310)
>         at
>         org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:621)
>         at
> org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:578)
>         at
> org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:686)
>         at
> org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
>         at java.lang.Thread.run(Thread.java:619)
> 
> 
> -- 
> View this message in context:
> http://lucene.472066.n3.nabble.com/configure-httpclient-to-access-solr-with-user-credential-on-third-party-host-tp2360364p2360364.html
> Sent from the Solr - User mailing list archive at Nabble.com.
> 
--- 
Enterprise Search Consultant at Sourcesense UK, 
Making Sense of Open Source