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 11006 Plater 7,872
Recognized Expert Expert
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
Plater 7,872
Recognized Expert Expert
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
Plater 7,872
Recognized Expert Expert
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_MACH INE instead of HKEY_CURRENT_US ER
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_nam e>service hung on starting.
any idea?
thank u in advance!
calin
Plater 7,872
Recognized Expert Expert
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 our Internet
proxy server (I was trying to contact an internal machine). Upon digging
into the code a little, I found that urllib2 was pulling the proxy
information out of the Windows registry (Internet Explorer uses these
settings). However,...
|
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 without a hitch).
Before I use this class, I make the necessary calls to
instantiate a WebProxy class and then pass in my
credentials to set the WebProxy.Credentials property so I
can get through the proxy server.
|
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 who are behind
SOCKS proxies.
My app also has corporate clients that are behind a HTTP proxy. Is
there a way for the windows app to consume a web service through a
HTTP proxy?
Please post any relevant code you have, THANKS!
|
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 you are developing on a machine that is behind a firewall and a proxy server has not been explicitly specified for Internet Explorer connections. You need to explicitly specify the address and port of the proxy server on your network in order to make...
|
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. Thanks in advance!
Here is what I'm doing:
In the windows app, I've set the current security principal as
windowsprincipal
| |
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 told remoting was the way
to go.
So I got a client and a server program up and going and from the client I
can call a routine in the server program. I can't figure out how to actually
send data to the client. At the moment the client calls a...
|
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 service run in an application pool which runs under a
domain user, this domain user has permissions of accessing database and the
connection to database is trusted connection. All these work well.
The web application will be used in internet (not...
|
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 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...
|
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 service as a console application, there are no problems. I can run svcutil.exe against that address and it generates the proxy. However, when I compile that service in release mode, and install it on the workstation using InstallUtil, I get an error...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |