hi
i am developing a windows application (VS 2008 - .net 3.5) which is requesting some data from a server (XML) and depends by results it is doing something
this application is using a UI for load/ save setings and a windows service which is requesting data at each 20 minutes.
i realized that the form (UI) has no problem to communicate with server (with or without proxy) but windows service is working only when is no proxy.
can somebody help me? can be an example in c# or vb.
i really appreciate it
calin
9 10877
What do you mean by "no proxy" and with a proxy?
If your browser is using a Proxy, it does not mean your service is using the proxy too.
Or do you mean like the network that the PC with the service is attached to, has a proxy server that applies to every PC on that network, without any settings on the PCs?
If a pxoy server is indeed being the middleman for your requests, the webserver is probably going "hey, this isn't the computer/service i requested the XML data from, it must be bad data/not mine" and either ignores it or throws an error
Hi Plater
all time the service is trying to access DIRECT (doesn't matter if in IE is seted up a proxy) - Dim objRequest As HttpWebRequest
-
objRequest = WebRequest.Create(URL + PostData)
-
Dim retProxy As WebProxy
-
Dim retURI As Uri
-
retURI = New Uri(URL)
-
retProxy = New WebProxy(WebRequest.DefaultWebProxy.GetProxy(retURI))
-
objRequest.Credentials = CredentialCache.DefaultCredentials
-
objRequest.Timeout = 30000 ' 30 secs
-
If retURI <> retProxy.Address Then
-
objRequest.Proxy = retProxy
-
End If
This code is working when is accessed from a form (working means that form is looking at IE proxy settings).. but id doesnot work when is accessed from windows service (windows service try to access DIRECT).
Thank you
Oh ok, let me make sure I understand this.
When you run the program as a form, the program gets the PROXY settings (via that default proxy settings) and works fine.
But as a SERVICE, the program is failing to get the proxy credentials?
I would venture that the problem is this: PROXY settings are generally on a "per user" level. When you run the program as a form, it gets the current user's proxy settings, which are configured. When run as a SERVICE, it runs as some other user (possibly some SYSTEM account) that does not have the PROXY server settings configured.
Try running the SERVICE with a specific user credentials that you know has the PROXY settings configured, and see if that helps?
Hi Plater
is all true what u said. the service is running like LocalSystem, but i need to be ran by localsystem. U know in vista is more complicate. for this i implemented Elevated method.
This service need to have ADMIN privileges. Any ideea how can i use default proxy in my windows service started like LocalSystem?
Thank you in advance
Calin
Hmm, the default proxy is the one configured by internet explorer right?
All those settings are kept in the registry.
Maybe you could find a way to either:
A) copy the registry keys over into the HKEY_LOCAL_MACHINE instead of HKEY_CURRENT_USER
B) Read the registry entry of another user and get the settings?
C) Find a way to apply the proxy settings to "all users of the computer)
Can't say as I know how to do any of those, but it might help you find something about it?
Hi Plater
i tried this, but u know virtualization in Vista! registry ideea is not good.
at setup process (installation) i am writing default proxy setings in a file. when i am running the service, i am reading the proxy from that file. i thought that this will solve the problem, but appear a new one:
The <my_service_name>service hung on starting.
any idea?
thank u in advance!
calin
Can you have your service output to its own log file somewhere?
Perhaps its throwing some kind of error that is not caught by eventlog stuff?
Just make an entry into that file like "Entering function: (whatever)", "leaving function (whatever)", etc etc
Then you could find where it is stalling out?
yes i implemented - Public Class pcksrv
-
Protected Overrides Sub OnStart(ByVal args() As String)
-
' Add code here to start your service. This method should set things
-
' in motion so your service can do its work.
-
LogInfo("Stariting the service")
-
myClock.Enabled = True
-
-
End Sub
-
-
Protected Overrides Sub OnStop()
-
LogInfo("Stoping the service")
-
myClock.Enabled = False
-
End Sub
-
-
Public Shared Sub LogInfo(ByVal sMessage As String)
-
' Write info into the event viewer
-
Try
-
Dim oEventLog As EventLog = New EventLog("Application")
-
If Not Diagnostics.EventLog.SourceExists("NotificationService") Then
-
Diagnostics.EventLog.CreateEventSource("NotificationService", "Application")
-
End If
-
Diagnostics.EventLog.WriteEntry("NotificationService", sMessage, _
-
System.Diagnostics.EventLogEntryType.Information)
-
Catch e As Exception
-
End Try
-
End Sub
-
-
Private Sub myClock_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myClock.Tick
-
LogInfo("Tic Tac 1")
-
CheckMyServer()
-
LogInfo("Tic Tac 2")
-
End Sub
-
End Class
-
but no luck, the service crashed before!
Please enclose your posted code in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [code] tags in future.
MODERATOR
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Carl Waldbieser |
last post by:
**** Post for FREE via your newsreader at post.usenet.com ****
When using urllib2.urlopen() on my Windows 2000 machine at work, I was
puzzled that I kept getting back authentication errors from...
|
by: Bill Hauver |
last post by:
I am attempting to use a web service from my work pc
which is behind a firewall. I have used wsdl.exe to
create the web service reference class and added it to my
project. (this seems to work...
|
by: Thomas Miller |
last post by:
Is there ANY way for a windows app to consume a web service by going
through a SOCKS proxy? This is a MUST for me because the windows app I
am building will be deployed to many corporate clients...
|
by: Jeffrey Tate via DotNetMonster.com |
last post by:
The error is:
The proxy settings on this computer are not configured correctly for Web discovery.
MSDN states that this is caused by:
This error appears in the Add Web Reference dialog box if...
|
by: webserviceUser189 |
last post by:
Hi,
I'm trying to authenticate the user based on the credentials that I get
from the client app, but I'm getting empty string as user name. Can somebody
tell me if I'm doing anything wrong here....
|
by: WinDev |
last post by:
We are trying to build a system where we have a Windows Service do some
manipulation of data, and then sending the data to a Windows App. I had
posted a question of how we should do this and was...
|
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= |
last post by:
Now I have a web application, a web service and a SQL Server database.
The Web application will invoke the web service, the web service
invokes the SQL Server stored procedure.
I let the web...
|
by: calinux |
last post by:
hi
i am developing a windows application (VS 2008 - .net 3.5) which is requesting some data from a server (XML) and depends by results it is doing something
this application is using a UI for...
|
by: khurramlone |
last post by:
I am trying to generate a client proxy from a WCF service library. I am using VS2005, .NET 3.0 on a Windows XP Pro workstation. The WCF service is hosted in a windows service. When I run the windows...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |